DEV: update syntax tree to latest (#24623)
update format to latest syntax tree
This commit is contained in:
parent
d40c0b698c
commit
b09422428d
|
@ -484,7 +484,7 @@ GEM
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sshkey (3.0.0)
|
sshkey (3.0.0)
|
||||||
stackprof (0.2.25)
|
stackprof (0.2.25)
|
||||||
syntax_tree (6.1.1)
|
syntax_tree (6.2.0)
|
||||||
prettier_print (>= 1.2.0)
|
prettier_print (>= 1.2.0)
|
||||||
syntax_tree-disable_ternary (1.0.0)
|
syntax_tree-disable_ternary (1.0.0)
|
||||||
test-prof (1.3.0)
|
test-prof (1.3.0)
|
||||||
|
|
|
@ -14,7 +14,6 @@ class Admin::ApiController < Admin::AdminController
|
||||||
ApiKey
|
ApiKey
|
||||||
.where(hidden: false)
|
.where(hidden: false)
|
||||||
.includes(:user, :api_key_scopes)
|
.includes(:user, :api_key_scopes)
|
||||||
# Sort revoked keys by revoked_at and active keys by created_at
|
|
||||||
.order("revoked_at DESC NULLS FIRST, created_at DESC")
|
.order("revoked_at DESC NULLS FIRST, created_at DESC")
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
|
@ -33,11 +33,11 @@ module Jobs
|
||||||
.where(
|
.where(
|
||||||
"uploads.retain_hours IS NULL OR uploads.created_at < current_timestamp - interval '1 hour' * uploads.retain_hours",
|
"uploads.retain_hours IS NULL OR uploads.created_at < current_timestamp - interval '1 hour' * uploads.retain_hours",
|
||||||
)
|
)
|
||||||
.where("uploads.created_at < ?", grace_period.hour.ago)
|
.where("uploads.created_at < ?", grace_period.hour.ago) # Don't remove any secure uploads.
|
||||||
# Don't remove any secure uploads.
|
|
||||||
.where("uploads.access_control_post_id IS NULL")
|
.where("uploads.access_control_post_id IS NULL")
|
||||||
.joins("LEFT JOIN upload_references ON upload_references.upload_id = uploads.id")
|
.joins(
|
||||||
# Don't remove any uploads linked to an UploadReference.
|
"LEFT JOIN upload_references ON upload_references.upload_id = uploads.id",
|
||||||
|
) # Don't remove any uploads linked to an UploadReference.
|
||||||
.where("upload_references.upload_id IS NULL")
|
.where("upload_references.upload_id IS NULL")
|
||||||
.with_no_non_post_relations
|
.with_no_non_post_relations
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,10 @@ class ApiKey < ActiveRecord::Base
|
||||||
scope :revoked, -> { where("revoked_at IS NOT NULL") }
|
scope :revoked, -> { where("revoked_at IS NOT NULL") }
|
||||||
|
|
||||||
scope :with_key,
|
scope :with_key,
|
||||||
->(key) {
|
->(key) do
|
||||||
hashed = self.hash_key(key)
|
hashed = self.hash_key(key)
|
||||||
where(key_hash: hashed)
|
where(key_hash: hashed)
|
||||||
}
|
end
|
||||||
|
|
||||||
validates :description, length: { maximum: 255 }
|
validates :description, length: { maximum: 255 }
|
||||||
|
|
||||||
|
|
|
@ -130,14 +130,14 @@ class Bookmark < ActiveRecord::Base
|
||||||
scope :with_reminders, -> { where("reminder_at IS NOT NULL") }
|
scope :with_reminders, -> { where("reminder_at IS NOT NULL") }
|
||||||
|
|
||||||
scope :pending_reminders,
|
scope :pending_reminders,
|
||||||
->(before_time = Time.now.utc) {
|
->(before_time = Time.now.utc) do
|
||||||
with_reminders.where("reminder_at <= ?", before_time).where(reminder_last_sent_at: nil)
|
with_reminders.where("reminder_at <= ?", before_time).where(reminder_last_sent_at: nil)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :pending_reminders_for_user, ->(user) { pending_reminders.where(user: user) }
|
scope :pending_reminders_for_user, ->(user) { pending_reminders.where(user: user) }
|
||||||
|
|
||||||
scope :for_user_in_topic,
|
scope :for_user_in_topic,
|
||||||
->(user_id, topic_id) {
|
->(user_id, topic_id) do
|
||||||
joins(
|
joins(
|
||||||
"LEFT JOIN posts ON posts.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Post'",
|
"LEFT JOIN posts ON posts.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Post'",
|
||||||
).joins(
|
).joins(
|
||||||
|
@ -149,7 +149,7 @@ class Bookmark < ActiveRecord::Base
|
||||||
user_id: user_id,
|
user_id: user_id,
|
||||||
topic_id: topic_id,
|
topic_id: topic_id,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
def self.count_per_day(opts = nil)
|
def self.count_per_day(opts = nil)
|
||||||
opts ||= {}
|
opts ||= {}
|
||||||
|
|
|
@ -170,7 +170,7 @@ class Category < ActiveRecord::Base
|
||||||
scope :latest, -> { order("topic_count DESC") }
|
scope :latest, -> { order("topic_count DESC") }
|
||||||
|
|
||||||
scope :secured,
|
scope :secured,
|
||||||
->(guardian = nil) {
|
->(guardian = nil) do
|
||||||
ids = guardian.secure_category_ids if guardian
|
ids = guardian.secure_category_ids if guardian
|
||||||
|
|
||||||
if ids.present?
|
if ids.present?
|
||||||
|
@ -181,13 +181,13 @@ class Category < ActiveRecord::Base
|
||||||
else
|
else
|
||||||
where("NOT categories.read_restricted").references(:categories)
|
where("NOT categories.read_restricted").references(:categories)
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
TOPIC_CREATION_PERMISSIONS ||= [:full]
|
TOPIC_CREATION_PERMISSIONS ||= [:full]
|
||||||
POST_CREATION_PERMISSIONS ||= %i[create_post full]
|
POST_CREATION_PERMISSIONS ||= %i[create_post full]
|
||||||
|
|
||||||
scope :topic_create_allowed,
|
scope :topic_create_allowed,
|
||||||
->(guardian) {
|
->(guardian) do
|
||||||
scoped = scoped_to_permissions(guardian, TOPIC_CREATION_PERMISSIONS)
|
scoped = scoped_to_permissions(guardian, TOPIC_CREATION_PERMISSIONS)
|
||||||
|
|
||||||
if !SiteSetting.allow_uncategorized_topics && !guardian.is_staff?
|
if !SiteSetting.allow_uncategorized_topics && !guardian.is_staff?
|
||||||
|
@ -195,7 +195,7 @@ class Category < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
scoped
|
scoped
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :post_create_allowed,
|
scope :post_create_allowed,
|
||||||
->(guardian) { scoped_to_permissions(guardian, POST_CREATION_PERMISSIONS) }
|
->(guardian) { scoped_to_permissions(guardian, POST_CREATION_PERMISSIONS) }
|
||||||
|
|
|
@ -10,12 +10,12 @@ class EmailToken < ActiveRecord::Base
|
||||||
|
|
||||||
scope :unconfirmed, -> { where(confirmed: false) }
|
scope :unconfirmed, -> { where(confirmed: false) }
|
||||||
scope :active,
|
scope :active,
|
||||||
-> {
|
-> do
|
||||||
where(expired: false).where(
|
where(expired: false).where(
|
||||||
"created_at >= ?",
|
"created_at >= ?",
|
||||||
SiteSetting.email_token_valid_hours.hours.ago,
|
SiteSetting.email_token_valid_hours.hours.ago,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
if self.token_hash.blank?
|
if self.token_hash.blank?
|
||||||
|
|
|
@ -17,22 +17,22 @@ class ExternalUploadStub < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :expired_created,
|
scope :expired_created,
|
||||||
-> {
|
-> do
|
||||||
where(
|
where(
|
||||||
"status = ? AND created_at <= ?",
|
"status = ? AND created_at <= ?",
|
||||||
ExternalUploadStub.statuses[:created],
|
ExternalUploadStub.statuses[:created],
|
||||||
CREATED_EXPIRY_HOURS.hours.ago,
|
CREATED_EXPIRY_HOURS.hours.ago,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :expired_uploaded,
|
scope :expired_uploaded,
|
||||||
-> {
|
-> do
|
||||||
where(
|
where(
|
||||||
"status = ? AND created_at <= ?",
|
"status = ? AND created_at <= ?",
|
||||||
ExternalUploadStub.statuses[:uploaded],
|
ExternalUploadStub.statuses[:uploaded],
|
||||||
UPLOADED_EXPIRY_HOURS.hours.ago,
|
UPLOADED_EXPIRY_HOURS.hours.ago,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
self.unique_identifier = SecureRandom.uuid
|
self.unique_identifier = SecureRandom.uuid
|
||||||
|
|
|
@ -25,14 +25,14 @@ class Notification < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
scope :unread_type, ->(user, type, limit = 30) { unread_types(user, [type], limit) }
|
scope :unread_type, ->(user, type, limit = 30) { unread_types(user, [type], limit) }
|
||||||
scope :unread_types,
|
scope :unread_types,
|
||||||
->(user, types, limit = 30) {
|
->(user, types, limit = 30) do
|
||||||
where(user_id: user.id, read: false, notification_type: types)
|
where(user_id: user.id, read: false, notification_type: types)
|
||||||
.visible
|
.visible
|
||||||
.includes(:topic)
|
.includes(:topic)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
}
|
end
|
||||||
scope :prioritized,
|
scope :prioritized,
|
||||||
->(deprioritized_types = []) {
|
->(deprioritized_types = []) do
|
||||||
scope = order("notifications.high_priority AND NOT notifications.read DESC")
|
scope = order("notifications.high_priority AND NOT notifications.read DESC")
|
||||||
if deprioritized_types.present?
|
if deprioritized_types.present?
|
||||||
scope =
|
scope =
|
||||||
|
@ -46,11 +46,11 @@ class Notification < ActiveRecord::Base
|
||||||
scope = scope.order("NOT notifications.read DESC")
|
scope = scope.order("NOT notifications.read DESC")
|
||||||
end
|
end
|
||||||
scope.order("notifications.created_at DESC")
|
scope.order("notifications.created_at DESC")
|
||||||
}
|
end
|
||||||
scope :for_user_menu,
|
scope :for_user_menu,
|
||||||
->(user_id, limit: 30) {
|
->(user_id, limit: 30) do
|
||||||
where(user_id: user_id).visible.prioritized.includes(:topic).limit(limit)
|
where(user_id: user_id).visible.prioritized.includes(:topic).limit(limit)
|
||||||
}
|
end
|
||||||
|
|
||||||
attr_accessor :skip_send_email
|
attr_accessor :skip_send_email
|
||||||
|
|
||||||
|
|
|
@ -89,13 +89,13 @@ class Post < ActiveRecord::Base
|
||||||
register_custom_field_type(NOTICE, :json)
|
register_custom_field_type(NOTICE, :json)
|
||||||
|
|
||||||
scope :private_posts_for_user,
|
scope :private_posts_for_user,
|
||||||
->(user) {
|
->(user) do
|
||||||
where(
|
where(
|
||||||
"topics.id IN (#{Topic::PRIVATE_MESSAGES_SQL_USER})
|
"topics.id IN (#{Topic::PRIVATE_MESSAGES_SQL_USER})
|
||||||
OR topics.id IN (#{Topic::PRIVATE_MESSAGES_SQL_GROUP})",
|
OR topics.id IN (#{Topic::PRIVATE_MESSAGES_SQL_GROUP})",
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :by_newest, -> { order("created_at DESC, id DESC") }
|
scope :by_newest, -> { order("created_at DESC, id DESC") }
|
||||||
scope :by_post_number, -> { order("post_number ASC") }
|
scope :by_post_number, -> { order("post_number ASC") }
|
||||||
|
@ -111,7 +111,7 @@ class Post < ActiveRecord::Base
|
||||||
->(guardian) { where("posts.post_type IN (?)", Topic.visible_post_types(guardian&.user)) }
|
->(guardian) { where("posts.post_type IN (?)", Topic.visible_post_types(guardian&.user)) }
|
||||||
|
|
||||||
scope :for_mailing_list,
|
scope :for_mailing_list,
|
||||||
->(user, since) {
|
->(user, since) do
|
||||||
q =
|
q =
|
||||||
created_since(since).joins(
|
created_since(since).joins(
|
||||||
"INNER JOIN (#{Topic.for_digest(user, Time.at(0)).select(:id).to_sql}) AS digest_topics ON digest_topics.id = posts.topic_id",
|
"INNER JOIN (#{Topic.for_digest(user, Time.at(0)).select(:id).to_sql}) AS digest_topics ON digest_topics.id = posts.topic_id",
|
||||||
|
@ -120,10 +120,10 @@ class Post < ActiveRecord::Base
|
||||||
|
|
||||||
q = q.where.not(post_type: Post.types[:whisper]) unless user.staff?
|
q = q.where.not(post_type: Post.types[:whisper]) unless user.staff?
|
||||||
q
|
q
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :raw_match,
|
scope :raw_match,
|
||||||
->(pattern, type = "string") {
|
->(pattern, type = "string") do
|
||||||
type = type&.downcase
|
type = type&.downcase
|
||||||
|
|
||||||
case type
|
case type
|
||||||
|
@ -132,10 +132,10 @@ class Post < ActiveRecord::Base
|
||||||
when "regex"
|
when "regex"
|
||||||
where("raw ~* ?", "(?n)#{pattern}")
|
where("raw ~* ?", "(?n)#{pattern}")
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :have_uploads,
|
scope :have_uploads,
|
||||||
-> {
|
-> do
|
||||||
where(
|
where(
|
||||||
"
|
"
|
||||||
(
|
(
|
||||||
|
@ -151,7 +151,7 @@ class Post < ActiveRecord::Base
|
||||||
)",
|
)",
|
||||||
"%/uploads/#{RailsMultisite::ConnectionManagement.current_db}/%",
|
"%/uploads/#{RailsMultisite::ConnectionManagement.current_db}/%",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
delegate :username, to: :user
|
delegate :username, to: :user
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,11 @@ class RemoteTheme < ActiveRecord::Base
|
||||||
|
|
||||||
has_one :theme, autosave: false
|
has_one :theme, autosave: false
|
||||||
scope :joined_remotes,
|
scope :joined_remotes,
|
||||||
-> {
|
-> do
|
||||||
joins("JOIN themes ON themes.remote_theme_id = remote_themes.id").where.not(
|
joins("JOIN themes ON themes.remote_theme_id = remote_themes.id").where.not(
|
||||||
remote_url: "",
|
remote_url: "",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
validates_format_of :minimum_discourse_version,
|
validates_format_of :minimum_discourse_version,
|
||||||
:maximum_discourse_version,
|
:maximum_discourse_version,
|
||||||
|
|
|
@ -22,18 +22,18 @@ class Tag < ActiveRecord::Base
|
||||||
validates :description, length: { maximum: 1000 }
|
validates :description, length: { maximum: 1000 }
|
||||||
|
|
||||||
scope :where_name,
|
scope :where_name,
|
||||||
->(name) {
|
->(name) do
|
||||||
name = Array(name).map(&:downcase)
|
name = Array(name).map(&:downcase)
|
||||||
where("lower(tags.name) IN (?)", name)
|
where("lower(tags.name) IN (?)", name)
|
||||||
}
|
end
|
||||||
|
|
||||||
# tags that have never been used and don't belong to a tag group
|
# tags that have never been used and don't belong to a tag group
|
||||||
scope :unused,
|
scope :unused,
|
||||||
-> {
|
-> do
|
||||||
where(staff_topic_count: 0, pm_topic_count: 0, target_tag_id: nil).joins(
|
where(staff_topic_count: 0, pm_topic_count: 0, target_tag_id: nil).joins(
|
||||||
"LEFT JOIN tag_group_memberships tgm ON tags.id = tgm.tag_id",
|
"LEFT JOIN tag_group_memberships tgm ON tags.id = tgm.tag_id",
|
||||||
).where("tgm.tag_id IS NULL")
|
).where("tgm.tag_id IS NULL")
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :used_tags_in_regular_topics,
|
scope :used_tags_in_regular_topics,
|
||||||
->(guardian) { where("tags.#{Tag.topic_count_column(guardian)} > 0") }
|
->(guardian) { where("tags.#{Tag.topic_count_column(guardian)} > 0") }
|
||||||
|
|
|
@ -5,7 +5,7 @@ class TagUser < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
scope :notification_level_visible,
|
scope :notification_level_visible,
|
||||||
->(notification_levels = TagUser.notification_levels.values) {
|
->(notification_levels = TagUser.notification_levels.values) do
|
||||||
select("tag_users.*")
|
select("tag_users.*")
|
||||||
.distinct
|
.distinct
|
||||||
.joins(
|
.joins(
|
||||||
|
@ -24,7 +24,7 @@ class TagUser < ActiveRecord::Base
|
||||||
everyone_group_id: Group::AUTO_GROUPS[:everyone],
|
everyone_group_id: Group::AUTO_GROUPS[:everyone],
|
||||||
notification_levels: notification_levels,
|
notification_levels: notification_levels,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
def self.notification_levels
|
def self.notification_levels
|
||||||
NotificationLevels.all
|
NotificationLevels.all
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Theme < ActiveRecord::Base
|
||||||
scope :user_selectable, -> { where("user_selectable OR id = ?", SiteSetting.default_theme_id) }
|
scope :user_selectable, -> { where("user_selectable OR id = ?", SiteSetting.default_theme_id) }
|
||||||
|
|
||||||
scope :include_relations,
|
scope :include_relations,
|
||||||
-> {
|
-> do
|
||||||
includes(
|
includes(
|
||||||
:child_themes,
|
:child_themes,
|
||||||
:parent_themes,
|
:parent_themes,
|
||||||
|
@ -88,7 +88,7 @@ class Theme < ActiveRecord::Base
|
||||||
:theme_translation_overrides,
|
:theme_translation_overrides,
|
||||||
theme_fields: :upload,
|
theme_fields: :upload,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
def notify_color_change(color, scheme: nil)
|
def notify_color_change(color, scheme: nil)
|
||||||
scheme ||= color.color_scheme
|
scheme ||= color.color_scheme
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ThemeField < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :find_by_theme_ids,
|
scope :find_by_theme_ids,
|
||||||
->(theme_ids) {
|
->(theme_ids) do
|
||||||
return none unless theme_ids.present?
|
return none unless theme_ids.present?
|
||||||
|
|
||||||
where(theme_id: theme_ids).joins(
|
where(theme_id: theme_ids).joins(
|
||||||
|
@ -27,10 +27,10 @@ class ThemeField < ActiveRecord::Base
|
||||||
SELECT #{theme_ids.map.with_index { |id, idx| "#{id.to_i} AS theme_id, #{idx} AS theme_sort_column" }.join(" UNION ALL SELECT ")}
|
SELECT #{theme_ids.map.with_index { |id, idx| "#{id.to_i} AS theme_id, #{idx} AS theme_sort_column" }.join(" UNION ALL SELECT ")}
|
||||||
) as X ON X.theme_id = theme_fields.theme_id",
|
) as X ON X.theme_id = theme_fields.theme_id",
|
||||||
).order("theme_sort_column")
|
).order("theme_sort_column")
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :filter_locale_fields,
|
scope :filter_locale_fields,
|
||||||
->(locale_codes) {
|
->(locale_codes) do
|
||||||
return none unless locale_codes.present?
|
return none unless locale_codes.present?
|
||||||
|
|
||||||
where(target_id: Theme.targets[:translations], name: locale_codes).joins(
|
where(target_id: Theme.targets[:translations], name: locale_codes).joins(
|
||||||
|
@ -41,20 +41,20 @@ class ThemeField < ActiveRecord::Base
|
||||||
*locale_codes.map.with_index { |code, index| [code, index] },
|
*locale_codes.map.with_index { |code, index| [code, index] },
|
||||||
),
|
),
|
||||||
).order("Y.locale_sort_column")
|
).order("Y.locale_sort_column")
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :find_first_locale_fields,
|
scope :find_first_locale_fields,
|
||||||
->(theme_ids, locale_codes) {
|
->(theme_ids, locale_codes) do
|
||||||
find_by_theme_ids(theme_ids)
|
find_by_theme_ids(theme_ids)
|
||||||
.filter_locale_fields(locale_codes)
|
.filter_locale_fields(locale_codes)
|
||||||
.reorder("X.theme_sort_column", "Y.locale_sort_column")
|
.reorder("X.theme_sort_column", "Y.locale_sort_column")
|
||||||
.select("DISTINCT ON (X.theme_sort_column) *")
|
.select("DISTINCT ON (X.theme_sort_column) *")
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :svg_sprite_fields,
|
scope :svg_sprite_fields,
|
||||||
-> {
|
-> do
|
||||||
where(type_id: ThemeField.theme_var_type_ids, name: SvgSprite.theme_sprite_variable_name)
|
where(type_id: ThemeField.theme_var_type_ids, name: SvgSprite.theme_sprite_variable_name)
|
||||||
}
|
end
|
||||||
|
|
||||||
def self.types
|
def self.types
|
||||||
@types ||=
|
@types ||=
|
||||||
|
|
|
@ -317,13 +317,13 @@ class Topic < ActiveRecord::Base
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
scope :private_messages_for_user,
|
scope :private_messages_for_user,
|
||||||
->(user) {
|
->(user) do
|
||||||
private_messages.where(
|
private_messages.where(
|
||||||
"topics.id IN (#{PRIVATE_MESSAGES_SQL_USER})
|
"topics.id IN (#{PRIVATE_MESSAGES_SQL_USER})
|
||||||
OR topics.id IN (#{PRIVATE_MESSAGES_SQL_GROUP})",
|
OR topics.id IN (#{PRIVATE_MESSAGES_SQL_GROUP})",
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :listable_topics, -> { where("topics.archetype <> ?", Archetype.private_message) }
|
scope :listable_topics, -> { where("topics.archetype <> ?", Archetype.private_message) }
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ class TopicTimer < ActiveRecord::Base
|
||||||
scope :scheduled_bump_topics,
|
scope :scheduled_bump_topics,
|
||||||
-> { where(status_type: TopicTimer.types[:bump], deleted_at: nil).pluck(:topic_id) }
|
-> { where(status_type: TopicTimer.types[:bump], deleted_at: nil).pluck(:topic_id) }
|
||||||
scope :pending_timers,
|
scope :pending_timers,
|
||||||
->(before_time = Time.now.utc) {
|
->(before_time = Time.now.utc) do
|
||||||
where("execute_at <= :before_time AND deleted_at IS NULL", before_time: before_time)
|
where("execute_at <= :before_time AND deleted_at IS NULL", before_time: before_time)
|
||||||
}
|
end
|
||||||
|
|
||||||
before_save do
|
before_save do
|
||||||
self.created_at ||= Time.zone.now if execute_at
|
self.created_at ||= Time.zone.now if execute_at
|
||||||
|
|
|
@ -103,7 +103,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :badges, through: :user_badges
|
has_many :badges, through: :user_badges
|
||||||
has_many :default_featured_user_badges,
|
has_many :default_featured_user_badges,
|
||||||
-> {
|
-> do
|
||||||
max_featured_rank =
|
max_featured_rank =
|
||||||
(
|
(
|
||||||
if SiteSetting.max_favorite_badges > 0
|
if SiteSetting.max_favorite_badges > 0
|
||||||
|
@ -113,7 +113,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
for_enabled_badges.grouped_with_count.where("featured_rank <= ?", max_featured_rank)
|
for_enabled_badges.grouped_with_count.where("featured_rank <= ?", max_featured_rank)
|
||||||
},
|
end,
|
||||||
class_name: "UserBadge"
|
class_name: "UserBadge"
|
||||||
|
|
||||||
has_many :topics_allowed, through: :topic_allowed_users, source: :topic
|
has_many :topics_allowed, through: :topic_allowed_users, source: :topic
|
||||||
|
@ -249,18 +249,18 @@ class User < ActiveRecord::Base
|
||||||
->(email) { joins(:user_emails).where("lower(user_emails.email) IN (?)", email) }
|
->(email) { joins(:user_emails).where("lower(user_emails.email) IN (?)", email) }
|
||||||
|
|
||||||
scope :with_primary_email,
|
scope :with_primary_email,
|
||||||
->(email) {
|
->(email) do
|
||||||
joins(:user_emails).where(
|
joins(:user_emails).where(
|
||||||
"lower(user_emails.email) IN (?) AND user_emails.primary",
|
"lower(user_emails.email) IN (?) AND user_emails.primary",
|
||||||
email,
|
email,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :human_users, -> { where("users.id > 0") }
|
scope :human_users, -> { where("users.id > 0") }
|
||||||
|
|
||||||
# excluding fake users like the system user or anonymous users
|
# excluding fake users like the system user or anonymous users
|
||||||
scope :real,
|
scope :real,
|
||||||
-> {
|
-> do
|
||||||
human_users.where(
|
human_users.where(
|
||||||
"NOT EXISTS(
|
"NOT EXISTS(
|
||||||
SELECT 1
|
SELECT 1
|
||||||
|
@ -268,7 +268,7 @@ class User < ActiveRecord::Base
|
||||||
WHERE a.user_id = users.id
|
WHERE a.user_id = users.id
|
||||||
)",
|
)",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
# TODO-PERF: There is no indexes on any of these
|
# TODO-PERF: There is no indexes on any of these
|
||||||
# and NotifyMailingListSubscribers does a select-all-and-loop
|
# and NotifyMailingListSubscribers does a select-all-and-loop
|
||||||
|
@ -281,16 +281,16 @@ class User < ActiveRecord::Base
|
||||||
scope :not_staged, -> { where(staged: false) }
|
scope :not_staged, -> { where(staged: false) }
|
||||||
|
|
||||||
scope :filter_by_username,
|
scope :filter_by_username,
|
||||||
->(filter) {
|
->(filter) do
|
||||||
if filter.is_a?(Array)
|
if filter.is_a?(Array)
|
||||||
where("username_lower ~* ?", "(#{filter.join("|")})")
|
where("username_lower ~* ?", "(#{filter.join("|")})")
|
||||||
else
|
else
|
||||||
where("username_lower ILIKE ?", "%#{filter}%")
|
where("username_lower ILIKE ?", "%#{filter}%")
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :filter_by_username_or_email,
|
scope :filter_by_username_or_email,
|
||||||
->(filter) {
|
->(filter) do
|
||||||
if filter.is_a?(String) && filter =~ /.+@.+/
|
if filter.is_a?(String) && filter =~ /.+@.+/
|
||||||
# probably an email so try the bypass
|
# probably an email so try the bypass
|
||||||
if user_id = UserEmail.where("lower(email) = ?", filter.downcase).pick(:user_id)
|
if user_id = UserEmail.where("lower(email) = ?", filter.downcase).pick(:user_id)
|
||||||
|
@ -311,10 +311,10 @@ class User < ActiveRecord::Base
|
||||||
filter: "%#{filter}%",
|
filter: "%#{filter}%",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :watching_topic,
|
scope :watching_topic,
|
||||||
->(topic) {
|
->(topic) do
|
||||||
joins(
|
joins(
|
||||||
DB.sql_fragment(
|
DB.sql_fragment(
|
||||||
"LEFT JOIN category_users ON category_users.user_id = users.id AND category_users.category_id = :category_id",
|
"LEFT JOIN category_users ON category_users.user_id = users.id AND category_users.category_id = :category_id",
|
||||||
|
@ -333,7 +333,7 @@ class User < ActiveRecord::Base
|
||||||
.where(
|
.where(
|
||||||
"category_users.notification_level > 0 OR topic_users.notification_level > 0 OR tag_users.notification_level > 0",
|
"category_users.notification_level > 0 OR topic_users.notification_level > 0 OR tag_users.notification_level > 0",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
module NewTopicDuration
|
module NewTopicDuration
|
||||||
ALWAYS = -1
|
ALWAYS = -1
|
||||||
|
|
|
@ -10,15 +10,15 @@ class UserBadge < ActiveRecord::Base
|
||||||
BOOLEAN_ATTRIBUTES = %w[is_favorite]
|
BOOLEAN_ATTRIBUTES = %w[is_favorite]
|
||||||
|
|
||||||
scope :grouped_with_count,
|
scope :grouped_with_count,
|
||||||
-> {
|
-> do
|
||||||
group(:badge_id, :user_id)
|
group(:badge_id, :user_id)
|
||||||
.select_for_grouping
|
.select_for_grouping
|
||||||
.order("MAX(featured_rank) ASC")
|
.order("MAX(featured_rank) ASC")
|
||||||
.includes(:user, :granted_by, { badge: :badge_type }, post: :topic)
|
.includes(:user, :granted_by, { badge: :badge_type }, post: :topic)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :select_for_grouping,
|
scope :select_for_grouping,
|
||||||
-> {
|
-> do
|
||||||
select(
|
select(
|
||||||
UserBadge.attribute_names.map do |name|
|
UserBadge.attribute_names.map do |name|
|
||||||
operation = BOOLEAN_ATTRIBUTES.include?(name) ? "BOOL_OR" : "MAX"
|
operation = BOOLEAN_ATTRIBUTES.include?(name) ? "BOOL_OR" : "MAX"
|
||||||
|
@ -26,7 +26,7 @@ class UserBadge < ActiveRecord::Base
|
||||||
end,
|
end,
|
||||||
'COUNT(*) AS "count"',
|
'COUNT(*) AS "count"',
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
scope :for_enabled_badges,
|
scope :for_enabled_badges,
|
||||||
-> { where("user_badges.badge_id IN (SELECT id FROM badges WHERE enabled)") }
|
-> { where("user_badges.badge_id IN (SELECT id FROM badges WHERE enabled)") }
|
||||||
|
|
|
@ -4,11 +4,11 @@ class UserCustomField < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
scope :searchable,
|
scope :searchable,
|
||||||
-> {
|
-> do
|
||||||
joins(
|
joins(
|
||||||
"INNER JOIN user_fields ON user_fields.id = REPLACE(user_custom_fields.name, 'user_field_', '')::INTEGER AND user_fields.searchable IS TRUE AND user_custom_fields.name like 'user_field_%'",
|
"INNER JOIN user_fields ON user_fields.id = REPLACE(user_custom_fields.name, 'user_field_', '')::INTEGER AND user_fields.searchable IS TRUE AND user_custom_fields.name like 'user_field_%'",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -27,12 +27,12 @@ class WatchedWord < ActiveRecord::Base
|
||||||
after_destroy -> { WordWatcher.clear_cache! }
|
after_destroy -> { WordWatcher.clear_cache! }
|
||||||
|
|
||||||
scope :for,
|
scope :for,
|
||||||
->(word:) {
|
->(word:) do
|
||||||
where(
|
where(
|
||||||
"(word ILIKE :word AND case_sensitive = 'f') OR (word LIKE :word AND case_sensitive = 't')",
|
"(word ILIKE :word AND case_sensitive = 'f') OR (word LIKE :word AND case_sensitive = 't')",
|
||||||
word: word,
|
word: word,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
def self.actions
|
def self.actions
|
||||||
@actions ||=
|
@actions ||=
|
||||||
|
|
|
@ -48,17 +48,17 @@ module Chat
|
||||||
before_validation :generate_auto_slug
|
before_validation :generate_auto_slug
|
||||||
|
|
||||||
scope :with_categories,
|
scope :with_categories,
|
||||||
-> {
|
-> do
|
||||||
joins(
|
joins(
|
||||||
"LEFT JOIN categories ON categories.id = chat_channels.chatable_id AND chat_channels.chatable_type = 'Category'",
|
"LEFT JOIN categories ON categories.id = chat_channels.chatable_id AND chat_channels.chatable_type = 'Category'",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
scope :public_channels,
|
scope :public_channels,
|
||||||
-> {
|
-> do
|
||||||
with_categories.where(chatable_type: public_channel_chatable_types).where(
|
with_categories.where(chatable_type: public_channel_chatable_types).where(
|
||||||
"categories.id IS NOT NULL",
|
"categories.id IS NOT NULL",
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
|
|
||||||
delegate :empty?, to: :chat_messages, prefix: true
|
delegate :empty?, to: :chat_messages, prefix: true
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ module Chat
|
||||||
dependent: :destroy,
|
dependent: :destroy,
|
||||||
foreign_key: :chat_message_id
|
foreign_key: :chat_message_id
|
||||||
has_many :bookmarks,
|
has_many :bookmarks,
|
||||||
-> {
|
-> do
|
||||||
unscope(where: :bookmarkable_type).where(
|
unscope(where: :bookmarkable_type).where(
|
||||||
bookmarkable_type: Chat::Message.polymorphic_name,
|
bookmarkable_type: Chat::Message.polymorphic_name,
|
||||||
)
|
)
|
||||||
},
|
end,
|
||||||
as: :bookmarkable,
|
as: :bookmarkable,
|
||||||
dependent: :destroy
|
dependent: :destroy
|
||||||
has_many :upload_references,
|
has_many :upload_references,
|
||||||
|
@ -53,21 +53,21 @@ module Chat
|
||||||
foreign_key: :chat_message_id
|
foreign_key: :chat_message_id
|
||||||
|
|
||||||
scope :in_public_channel,
|
scope :in_public_channel,
|
||||||
-> {
|
-> do
|
||||||
joins(:chat_channel).where(
|
joins(:chat_channel).where(
|
||||||
chat_channel: {
|
chat_channel: {
|
||||||
chatable_type: Chat::Channel.public_channel_chatable_types,
|
chatable_type: Chat::Channel.public_channel_chatable_types,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
scope :in_dm_channel,
|
scope :in_dm_channel,
|
||||||
-> {
|
-> do
|
||||||
joins(:chat_channel).where(
|
joins(:chat_channel).where(
|
||||||
chat_channel: {
|
chat_channel: {
|
||||||
chatable_type: Chat::Channel.direct_channel_chatable_types,
|
chatable_type: Chat::Channel.direct_channel_chatable_types,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
scope :created_before, ->(date) { where("chat_messages.created_at < ?", date) }
|
scope :created_before, ->(date) { where("chat_messages.created_at < ?", date) }
|
||||||
scope :uncooked, -> { where("cooked_version <> ? or cooked_version IS NULL", BAKED_VERSION) }
|
scope :uncooked, -> { where("cooked_version <> ? or cooked_version IS NULL", BAKED_VERSION) }
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@ module Chat
|
||||||
class_name: "Chat::Message"
|
class_name: "Chat::Message"
|
||||||
|
|
||||||
has_many :chat_messages,
|
has_many :chat_messages,
|
||||||
-> {
|
-> do
|
||||||
where("deleted_at IS NULL").order(
|
where("deleted_at IS NULL").order(
|
||||||
"chat_messages.created_at ASC, chat_messages.id ASC",
|
"chat_messages.created_at ASC, chat_messages.id ASC",
|
||||||
)
|
)
|
||||||
},
|
end,
|
||||||
foreign_key: :thread_id,
|
foreign_key: :thread_id,
|
||||||
primary_key: :id,
|
primary_key: :id,
|
||||||
class_name: "Chat::Message"
|
class_name: "Chat::Message"
|
||||||
|
|
|
@ -25,27 +25,27 @@ RSpec.describe BackupRestore::S3BackupStore do
|
||||||
|
|
||||||
@s3_client.stub_responses(
|
@s3_client.stub_responses(
|
||||||
:list_objects_v2,
|
:list_objects_v2,
|
||||||
->(context) {
|
->(context) do
|
||||||
check_context(context)
|
check_context(context)
|
||||||
|
|
||||||
{ contents: objects_with_prefix(context) }
|
{ contents: objects_with_prefix(context) }
|
||||||
},
|
end,
|
||||||
)
|
)
|
||||||
|
|
||||||
@s3_client.stub_responses(
|
@s3_client.stub_responses(
|
||||||
:delete_object,
|
:delete_object,
|
||||||
->(context) {
|
->(context) do
|
||||||
check_context(context)
|
check_context(context)
|
||||||
|
|
||||||
expect do @objects.delete_if { |obj| obj[:key] == context.params[:key] } end.to change {
|
expect do @objects.delete_if { |obj| obj[:key] == context.params[:key] } end.to change {
|
||||||
@objects
|
@objects
|
||||||
}
|
}
|
||||||
},
|
end,
|
||||||
)
|
)
|
||||||
|
|
||||||
@s3_client.stub_responses(
|
@s3_client.stub_responses(
|
||||||
:head_object,
|
:head_object,
|
||||||
->(context) {
|
->(context) do
|
||||||
check_context(context)
|
check_context(context)
|
||||||
|
|
||||||
if object = @objects.find { |obj| obj[:key] == context.params[:key] }
|
if object = @objects.find { |obj| obj[:key] == context.params[:key] }
|
||||||
|
@ -53,12 +53,12 @@ RSpec.describe BackupRestore::S3BackupStore do
|
||||||
else
|
else
|
||||||
{ status_code: 404, headers: {}, body: "" }
|
{ status_code: 404, headers: {}, body: "" }
|
||||||
end
|
end
|
||||||
},
|
end,
|
||||||
)
|
)
|
||||||
|
|
||||||
@s3_client.stub_responses(
|
@s3_client.stub_responses(
|
||||||
:get_object,
|
:get_object,
|
||||||
->(context) {
|
->(context) do
|
||||||
check_context(context)
|
check_context(context)
|
||||||
|
|
||||||
if object = @objects.find { |obj| obj[:key] == context.params[:key] }
|
if object = @objects.find { |obj| obj[:key] == context.params[:key] }
|
||||||
|
@ -66,12 +66,12 @@ RSpec.describe BackupRestore::S3BackupStore do
|
||||||
else
|
else
|
||||||
{ status_code: 404, headers: {}, body: "" }
|
{ status_code: 404, headers: {}, body: "" }
|
||||||
end
|
end
|
||||||
},
|
end,
|
||||||
)
|
)
|
||||||
|
|
||||||
@s3_client.stub_responses(
|
@s3_client.stub_responses(
|
||||||
:put_object,
|
:put_object,
|
||||||
->(context) {
|
->(context) do
|
||||||
check_context(context)
|
check_context(context)
|
||||||
|
|
||||||
@objects << {
|
@objects << {
|
||||||
|
@ -79,7 +79,7 @@ RSpec.describe BackupRestore::S3BackupStore do
|
||||||
size: context.params[:body].size,
|
size: context.params[:body].size,
|
||||||
last_modified: Time.zone.now,
|
last_modified: Time.zone.now,
|
||||||
}
|
}
|
||||||
},
|
end,
|
||||||
)
|
)
|
||||||
|
|
||||||
SiteSetting.s3_backup_bucket = "s3-backup-bucket"
|
SiteSetting.s3_backup_bucket = "s3-backup-bucket"
|
||||||
|
|
|
@ -130,9 +130,9 @@ RSpec.describe InlineOneboxer do
|
||||||
topic = Fabricate(:topic, title: "Inline oneboxer")
|
topic = Fabricate(:topic, title: "Inline oneboxer")
|
||||||
Fabricate(:post, topic: topic) # OP
|
Fabricate(:post, topic: topic) # OP
|
||||||
Fabricate(:post, topic: topic)
|
Fabricate(:post, topic: topic)
|
||||||
lookup = ->(number) {
|
lookup = ->(number) do
|
||||||
InlineOneboxer.lookup("#{topic.url}/#{number}", skip_cache: true)[:title]
|
InlineOneboxer.lookup("#{topic.url}/#{number}", skip_cache: true)[:title]
|
||||||
}
|
end
|
||||||
posts = topic.reload.posts.order("post_number ASC")
|
posts = topic.reload.posts.order("post_number ASC")
|
||||||
|
|
||||||
expect(lookup.call(0)).to eq("Inline oneboxer")
|
expect(lookup.call(0)).to eq("Inline oneboxer")
|
||||||
|
|
|
@ -667,10 +667,10 @@ RSpec.describe Middleware::RequestTracker do
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:logger) do
|
let(:logger) do
|
||||||
->(env, data) {
|
->(env, data) do
|
||||||
@env = env
|
@env = env
|
||||||
@data = data
|
@data = data
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before { Middleware::RequestTracker.register_detailed_request_logger(logger) }
|
before { Middleware::RequestTracker.register_detailed_request_logger(logger) }
|
||||||
|
|
|
@ -382,9 +382,9 @@ RSpec.describe NewPostManager do
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
@queue_handler = ->(manager) {
|
@queue_handler = ->(manager) do
|
||||||
manager.args[:raw] =~ /queue me/ ? manager.enqueue("default") : nil
|
manager.args[:raw] =~ /queue me/ ? manager.enqueue("default") : nil
|
||||||
}
|
end
|
||||||
|
|
||||||
NewPostManager.add_handler(&@counter_handler)
|
NewPostManager.add_handler(&@counter_handler)
|
||||||
NewPostManager.add_handler(&@queue_handler)
|
NewPostManager.add_handler(&@queue_handler)
|
||||||
|
|
|
@ -771,12 +771,12 @@ RSpec.describe Plugin::Instance do
|
||||||
to: Notification.types[:code_review_commit_approved],
|
to: Notification.types[:code_review_commit_approved],
|
||||||
threshold: 1,
|
threshold: 1,
|
||||||
consolidation_window: 1.minute,
|
consolidation_window: 1.minute,
|
||||||
unconsolidated_query_blk: ->(notifications, _data) {
|
unconsolidated_query_blk: ->(notifications, _data) do
|
||||||
notifications.where("(data::json ->> 'consolidated') IS NULL")
|
notifications.where("(data::json ->> 'consolidated') IS NULL")
|
||||||
},
|
end,
|
||||||
consolidated_query_blk: ->(notifications, _data) {
|
consolidated_query_blk: ->(notifications, _data) do
|
||||||
notifications.where("(data::json ->> 'consolidated') IS NOT NULL")
|
notifications.where("(data::json ->> 'consolidated') IS NOT NULL")
|
||||||
},
|
end,
|
||||||
).set_mutations(
|
).set_mutations(
|
||||||
set_data_blk: ->(notification) { notification.data_hash.merge(consolidated: true) },
|
set_data_blk: ->(notification) { notification.data_hash.merge(consolidated: true) },
|
||||||
)
|
)
|
||||||
|
|
|
@ -391,11 +391,11 @@ RSpec.describe PostDestroyer do
|
||||||
user_stat = post2.user.user_stat
|
user_stat = post2.user.user_stat
|
||||||
|
|
||||||
called = 0
|
called = 0
|
||||||
topic_destroyed = ->(topic, user) {
|
topic_destroyed = ->(topic, user) do
|
||||||
expect(topic).to eq(post2.topic)
|
expect(topic).to eq(post2.topic)
|
||||||
expect(user).to eq(post2.user)
|
expect(user).to eq(post2.user)
|
||||||
called += 1
|
called += 1
|
||||||
}
|
end
|
||||||
|
|
||||||
DiscourseEvent.on(:topic_destroyed, &topic_destroyed)
|
DiscourseEvent.on(:topic_destroyed, &topic_destroyed)
|
||||||
|
|
||||||
|
@ -414,11 +414,11 @@ RSpec.describe PostDestroyer do
|
||||||
expect(user_stat.reload.topic_count).to eq(1)
|
expect(user_stat.reload.topic_count).to eq(1)
|
||||||
|
|
||||||
called = 0
|
called = 0
|
||||||
topic_recovered = ->(topic, user) {
|
topic_recovered = ->(topic, user) do
|
||||||
expect(topic).to eq(post2.topic)
|
expect(topic).to eq(post2.topic)
|
||||||
expect(user).to eq(post2.user)
|
expect(user).to eq(post2.user)
|
||||||
called += 1
|
called += 1
|
||||||
}
|
end
|
||||||
|
|
||||||
DiscourseEvent.on(:topic_recovered, &topic_recovered)
|
DiscourseEvent.on(:topic_recovered, &topic_recovered)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ RSpec.describe "S3Inventory" do
|
||||||
|
|
||||||
client.stub_responses(
|
client.stub_responses(
|
||||||
:list_objects,
|
:list_objects,
|
||||||
->(context) {
|
->(context) do
|
||||||
expect(context.params[:prefix]).to eq(
|
expect(context.params[:prefix]).to eq(
|
||||||
"#{S3Inventory::INVENTORY_PREFIX}/#{S3Inventory::INVENTORY_VERSION}/bucket/original/hive",
|
"#{S3Inventory::INVENTORY_PREFIX}/#{S3Inventory::INVENTORY_VERSION}/bucket/original/hive",
|
||||||
)
|
)
|
||||||
|
@ -48,7 +48,7 @@ RSpec.describe "S3Inventory" do
|
||||||
],
|
],
|
||||||
next_marker: "eyJNYXJrZXIiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==",
|
next_marker: "eyJNYXJrZXIiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==",
|
||||||
}
|
}
|
||||||
},
|
end,
|
||||||
)
|
)
|
||||||
|
|
||||||
inventory.stubs(:cleanup!)
|
inventory.stubs(:cleanup!)
|
||||||
|
|
|
@ -206,14 +206,14 @@ RSpec.describe Report do
|
||||||
if arg == :flag
|
if arg == :flag
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
topic = Fabricate(:topic, user: user)
|
topic = Fabricate(:topic, user: user)
|
||||||
builder = ->(dt) {
|
builder = ->(dt) do
|
||||||
PostActionCreator.create(
|
PostActionCreator.create(
|
||||||
user,
|
user,
|
||||||
Fabricate(:post, topic: topic, user: user),
|
Fabricate(:post, topic: topic, user: user),
|
||||||
:spam,
|
:spam,
|
||||||
created_at: dt,
|
created_at: dt,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
elsif arg == :signup
|
elsif arg == :signup
|
||||||
builder = ->(dt) { Fabricate(:user, created_at: dt) }
|
builder = ->(dt) { Fabricate(:user, created_at: dt) }
|
||||||
else
|
else
|
||||||
|
|
|
@ -590,10 +590,10 @@ RSpec.describe TopicUser do
|
||||||
|
|
||||||
called = 0
|
called = 0
|
||||||
visits = []
|
visits = []
|
||||||
user_first_visit = ->(topic_id, user_id) {
|
user_first_visit = ->(topic_id, user_id) do
|
||||||
visits << "#{topic_id}-#{user_id}"
|
visits << "#{topic_id}-#{user_id}"
|
||||||
called += 1
|
called += 1
|
||||||
}
|
end
|
||||||
|
|
||||||
DiscourseEvent.on(:topic_first_visited_by_user, &user_first_visit)
|
DiscourseEvent.on(:topic_first_visited_by_user, &user_first_visit)
|
||||||
|
|
||||||
|
|
|
@ -309,11 +309,11 @@ RSpec.describe TopicsController do
|
||||||
begin
|
begin
|
||||||
called = false
|
called = false
|
||||||
|
|
||||||
assert = ->(original_topic, destination_topic) {
|
assert = ->(original_topic, destination_topic) do
|
||||||
called = true
|
called = true
|
||||||
expect(original_topic).to eq(topic)
|
expect(original_topic).to eq(topic)
|
||||||
expect(destination_topic).to eq(dest_topic)
|
expect(destination_topic).to eq(dest_topic)
|
||||||
}
|
end
|
||||||
|
|
||||||
DiscourseEvent.on(:topic_merged, &assert)
|
DiscourseEvent.on(:topic_merged, &assert)
|
||||||
|
|
||||||
|
|
|
@ -70,10 +70,10 @@ RSpec.describe UserSilencer do
|
||||||
|
|
||||||
context "with a plugin hook" do
|
context "with a plugin hook" do
|
||||||
before do
|
before do
|
||||||
@override_silence_message = ->(opts) {
|
@override_silence_message = ->(opts) do
|
||||||
opts[:silence_message_params][:message_title] = "override title"
|
opts[:silence_message_params][:message_title] = "override title"
|
||||||
opts[:silence_message_params][:message_raw] = "override raw"
|
opts[:silence_message_params][:message_raw] = "override raw"
|
||||||
}
|
end
|
||||||
|
|
||||||
DiscourseEvent.on(:user_silenced, &@override_silence_message)
|
DiscourseEvent.on(:user_silenced, &@override_silence_message)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue