A platform for community discussion. Free, open, simple.
DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073)
Jarek Radosz71834c898f2f
diff --git a/Gemfile.lock b/Gemfile.lockindex 2985ea2886e..0a77cf914f5 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -562,7 +562,7 @@ GEMrubocop-capybara (2.22.1)lint_roller (~> 1.1)rubocop (~> 1.72, >= 1.72.1)- rubocop-discourse (3.12.1)+ rubocop-discourse (3.13.3)activesupport (>= 6.1)lint_roller (>= 1.1.0)rubocop (>= 1.73.2)@@ -1156,7 +1156,7 @@ CHECKSUMSrubocop (1.81.1) sha256=352a9a6f314a4312f6c305f1f72bc466254d221c95445cd49e1b65d1f9411635rubocop-ast (1.47.1) sha256=592682017855408b046a8190689490763aecea175238232b1b526826349d01aerubocop-capybara (2.22.1) sha256=ced88caef23efea53f46e098ff352f8fc1068c649606ca75cb74650970f51c0c- rubocop-discourse (3.12.1) sha256=ebf7e2224f053047372071419052828c3e3a01bccb14ea1f282ac143547df9bc+ rubocop-discourse (3.13.3) sha256=637395e37ac45f0c5ba4376d7648b5f1e3a8406697c38befb66a9729738a059frubocop-factory_bot (2.27.1) sha256=9d744b5916778c1848e5fe6777cc69855bd96548853554ec239ba9961b8573ferubocop-rails (2.33.4) sha256=34ec8f6637706dc224483d949ccc88b3e41596a81a11a1ec0c7d74ecbea356b5rubocop-rspec (3.7.0) sha256=b7b214da112034db9c6d00f2d811a354847e870f7b6ed2482b29649c3d42058fdiff --git a/app/controllers/admin/admin_notices_controller.rb b/app/controllers/admin/admin_notices_controller.rbindex 44c787abb87..5f22a7ddf25 100644--- a/app/controllers/admin/admin_notices_controller.rb+++ b/app/controllers/admin/admin_notices_controller.rb@@ -4,7 +4,7 @@ class Admin::AdminNoticesController < Admin::StaffControllerdef destroyAdminNotices::Dismiss.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }endendenddiff --git a/app/controllers/admin/api_controller.rb b/app/controllers/admin/api_controller.rbindex 4bc15407627..acb48730665 100644--- a/app/controllers/admin/api_controller.rb+++ b/app/controllers/admin/api_controller.rb@@ -27,7 +27,7 @@ class Admin::ApiController < Admin::AdminControllerenddef show- api_key = ApiKey.includes(:api_key_scopes).find_by!(id: params[:id])+ api_key = ApiKey.includes(:api_key_scopes).find(params[:id])render_serialized(api_key, ApiKeySerializer, root: "key")end@@ -53,7 +53,7 @@ class Admin::ApiController < Admin::AdminControllerenddef update- api_key = ApiKey.find_by!(id: params[:id])+ api_key = ApiKey.find(params[:id])ApiKey.transaction doapi_key.update!(update_params)log_api_key(api_key, UserHistory.actions[:api_key_update], changes: api_key.saved_changes)@@ -62,7 +62,7 @@ class Admin::ApiController < Admin::AdminControllerenddef destroy- api_key = ApiKey.find_by!(id: params[:id])+ api_key = ApiKey.find(params[:id])ApiKey.transaction doapi_key.destroylog_api_key(api_key, UserHistory.actions[:api_key_destroy])diff --git a/app/controllers/admin/backups_controller.rb b/app/controllers/admin/backups_controller.rbindex e19d2a55614..c81e3bf308a 100644--- a/app/controllers/admin/backups_controller.rb+++ b/app/controllers/admin/backups_controller.rb@@ -89,14 +89,14 @@ class Admin::BackupsController < Admin::AdminControllerrender body: nilelse- render body: nil, status: 404+ render body: nil, status: :not_foundendenddef showif !EmailBackupToken.compare(current_user.id, params.fetch(:token))@error = I18n.t("download_backup_mailer.no_token")- return render layout: "no_ember", status: 422, formats: [:html]+ return render layout: "no_ember", status: :unprocessable_entity, formats: [:html]endstore = BackupRestore::BackupStore.create@@ -112,7 +112,7 @@ class Admin::BackupsController < Admin::AdminControllersend_file backup.sourceendelse- render body: nil, status: 404+ render body: nil, status: :not_foundendend@@ -124,7 +124,7 @@ class Admin::BackupsController < Admin::AdminControllerstore.delete_file(backup.filename)render body: nilelse- render body: nil, status: 404+ render body: nil, status: :not_foundendend@@ -193,13 +193,17 @@ class Admin::BackupsController < Admin::AdminControllerraise Discourse::InvalidParameters.new(:resumableIdentifier) unless valid_filename?(identifier)unless valid_extension?(filename)- return render status: 415, plain: I18n.t("backup.backup_file_should_be_tar_gz")+ return(+ render status: :unsupported_media_type, plain: I18n.t("backup.backup_file_should_be_tar_gz")+ )endunless has_enough_space_on_disk?(total_size)- return render status: 415, plain: I18n.t("backup.not_enough_space_on_disk")+ return(+ render status: :unsupported_media_type, plain: I18n.t("backup.not_enough_space_on_disk")+ )endunless valid_filename?(filename)- return render status: 415, plain: I18n.t("backup.invalid_filename")+ return render status: :unsupported_media_type, plain: I18n.t("backup.invalid_filename")endfile = params.fetch(:file)diff --git a/app/controllers/admin/badges_controller.rb b/app/controllers/admin/badges_controller.rbindex 198cd967b1d..901fee1b2b3 100644--- a/app/controllers/admin/badges_controller.rb+++ b/app/controllers/admin/badges_controller.rb@@ -24,7 +24,9 @@ class Admin::BadgesController < Admin::AdminControllerenddef preview- return render json: "preview not allowed", status: 403 unless SiteSetting.enable_badge_sql+ unless SiteSetting.enable_badge_sql+ return render json: "preview not allowed", status: :forbidden+ endrender json:BadgeGranter.preview(diff --git a/app/controllers/admin/config/flags_controller.rb b/app/controllers/admin/config/flags_controller.rbindex c0f3f888ebc..815535dfd2c 100644--- a/app/controllers/admin/config/flags_controller.rb+++ b/app/controllers/admin/config/flags_controller.rb@@ -7,11 +7,11 @@ class Admin::Config::FlagsController < Admin::AdminControllerDiscourse.request_refresh!render(json: success_json)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -31,11 +31,11 @@ class Admin::Config::FlagsController < Admin::AdminControllerDiscourse.request_refresh!render json: flag, serializer: FlagSerializerend- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_policy(:unique_name) { render_json_error(I18n.t("flags.errors.unique_name")) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -46,14 +46,14 @@ class Admin::Config::FlagsController < Admin::AdminControllerDiscourse.request_refresh!render json: flag, serializer: FlagSerializerend- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_policy(:not_system) { render_json_error(I18n.t("flags.errors.system")) }on_failed_policy(:not_used) { render_json_error(I18n.t("flags.errors.used")) }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_policy(:unique_name) { render_json_error(I18n.t("flags.errors.unique_name")) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -64,12 +64,12 @@ class Admin::Config::FlagsController < Admin::AdminControllerDiscourse.request_refresh!render(json: success_json)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_policy(:invalid_move) { render_json_error(I18n.t("flags.errors.wrong_move")) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -80,12 +80,12 @@ class Admin::Config::FlagsController < Admin::AdminControllerDiscourse.request_refresh!render(json: success_json)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:not_system) { render_json_error(I18n.t("flags.errors.system")) }on_failed_policy(:not_used) { render_json_error(I18n.t("flags.errors.used")) }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rbindex 2253b89abb7..5df42c0a9ce 100644--- a/app/controllers/admin/dashboard_controller.rb+++ b/app/controllers/admin/dashboard_controller.rb@@ -63,11 +63,11 @@ class Admin::DashboardController < Admin::StaffControllerdef toggle_featureExperiments::Toggle.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:current_user_is_admin) { raise Discourse::InvalidAccess }on_failed_policy(:setting_is_available) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/app/controllers/admin/email_controller.rb b/app/controllers/admin/email_controller.rbindex 0d00cc2c9e6..b8a5fd290af 100644--- a/app/controllers/admin/email_controller.rb+++ b/app/controllers/admin/email_controller.rb@@ -17,7 +17,7 @@ class Admin::EmailController < Admin::AdminControllerrender json: { sent_test_email_message: I18n.t("admin.email.sent_test") }rescue => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendend@@ -55,7 +55,7 @@ class Admin::EmailController < Admin::AdminControllerEmail::Sender.new(message, :digest).sendrender json: success_jsonrescue => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendelserender json: { errors: skip_reason }diff --git a/app/controllers/admin/email_logs_controller.rb b/app/controllers/admin/email_logs_controller.rbindex 65a6d0b069c..2e2b9e1c549 100644--- a/app/controllers/admin/email_logs_controller.rb+++ b/app/controllers/admin/email_logs_controller.rb@@ -96,7 +96,7 @@ class Admin::EmailLogsController < Admin::AdminControllerserializer = IncomingEmailDetailsSerializer.new(incoming_email, root: false)render_json_dump(serializer)rescue => e- render json: { errors: [e.message] }, status: 404+ render json: { errors: [e.message] }, status: :not_foundendenddiff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rbindex dcd100c2499..5266a552194 100644--- a/app/controllers/admin/reports_controller.rb+++ b/app/controllers/admin/reports_controller.rb@@ -87,7 +87,7 @@ class Admin::ReportsController < Admin::StaffControllerif report_params[:start_date].present?Time.parse(report_params[:start_date]).to_dateelse- 1.days.ago+ 1.day.agoend).beginning_of_dayend_date =diff --git a/app/controllers/admin/site_texts_controller.rb b/app/controllers/admin/site_texts_controller.rbindex b79352dd1c7..9d3118de664 100644--- a/app/controllers/admin/site_texts_controller.rb+++ b/app/controllers/admin/site_texts_controller.rb@@ -106,7 +106,7 @@ class Admin::SiteTextsController < Admin::AdminControllerelserender json:failed_json.merge(message: translation_override.errors.full_messages.join("\n\n")),- status: 422+ status: :unprocessable_entityendend@@ -140,7 +140,8 @@ class Admin::SiteTextsController < Admin::AdminControllerif override.make_up_to_date!render json: success_jsonelse- render json: failed_json.merge(message: "Can only dismiss outdated translations"), status: 422+ render json: failed_json.merge(message: "Can only dismiss outdated translations"),+ status: :unprocessable_entityendenddiff --git a/app/controllers/admin/themes_controller.rb b/app/controllers/admin/themes_controller.rbindex c20b3df47cb..2fef9399a9d 100644--- a/app/controllers/admin/themes_controller.rb+++ b/app/controllers/admin/themes_controller.rb@@ -205,13 +205,13 @@ class Admin::ThemesController < Admin::AdminController) doon_success { |theme:| render json: serialize_data(theme, ThemeSerializer), status: :created }on_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_requestendon_failed_policy(:ensure_remote_themes_are_not_allowlisted) { raise Discourse::InvalidAccess }on_model_errors { |theme:| render json: theme.errors, status: :unprocessable_entity }on_model_not_found(:theme) do |result|raise Discourse::NotFound if !result.exception- render json: failed_json.merge(errors: result.exception.message), status: 400+ render json: failed_json.merge(errors: result.exception.message), status: :bad_requestendendend@@ -291,7 +291,7 @@ class Admin::ThemesController < Admin::AdminControllerThemes::Destroy.call(service_params) doon_success { head :no_content }on_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_requestendon_model_not_found(:theme) { raise Discourse::NotFound }end@@ -301,7 +301,7 @@ class Admin::ThemesController < Admin::AdminControllerThemes::BulkDestroy.call(service_params) doon_success { head :no_content }on_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_requestendon_model_not_found(:themes) { raise Discourse::NotFound }end@@ -333,7 +333,7 @@ class Admin::ThemesController < Admin::AdminControllerThemes::GetTranslations.call(service_params) doon_success { |translations:| render(json: success_json.merge(translations:)) }on_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_requestendon_failed_policy(:validate_locale) { raise Discourse::InvalidParameters.new(:locale) }on_model_not_found(:theme) { raise Discourse::NotFound }diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rbindex 315a1648239..8d94fac4f4b 100644--- a/app/controllers/admin/users_controller.rb+++ b/app/controllers/admin/users_controller.rb@@ -135,11 +135,11 @@ class Admin::UsersController < Admin::StaffController)endon_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_requestendon_model_not_found(:user) { raise Discourse::NotFound }on_failed_policy(:not_suspended_already) do |policy|- render json: failed_json.merge(message: policy.reason), status: 409+ render json: failed_json.merge(message: policy.reason), status: :conflictendon_failed_policy(:can_suspend_all_users) { raise Discourse::InvalidAccess.new }end@@ -163,7 +163,7 @@ class Admin::UsersController < Admin::StaffController@user.logged_outrender json: success_jsonelse- render json: { error: I18n.t("admin_js.admin.users.id_not_found") }, status: 404+ render json: { error: I18n.t("admin_js.admin.users.id_not_found") }, status: :not_foundendend@@ -335,11 +335,11 @@ class Admin::UsersController < Admin::StaffController)endon_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_requestendon_model_not_found(:user) { raise Discourse::NotFound }on_failed_policy(:not_silenced_already) do |policy|- render json: failed_json.merge(message: policy.reason), status: 409+ render json: failed_json.merge(message: policy.reason), status: :conflictendon_failed_policy(:can_silence_all_users) { raise Discourse::InvalidAccess.new }end@@ -404,7 +404,7 @@ class Admin::UsersController < Admin::StaffControllercount: user.posts.joins(:topic).count,),},- status: 403+ status: :forbiddenendendend@@ -419,14 +419,16 @@ class Admin::UsersController < Admin::StaffControlleron_success { render json: { deleted: true } }on_failed_contract do |contract|- render json: failed_json.merge(errors: contract.errors.full_messages), status: 400+ render json: failed_json.merge(errors: contract.errors.full_messages),+ status: :bad_requestendon_failed_policy(:can_delete_users) do- render json: failed_json.merge(errors: [I18n.t("user.cannot_bulk_delete")]), status: 403+ render json: failed_json.merge(errors: [I18n.t("user.cannot_bulk_delete")]),+ status: :forbiddenend- on_model_not_found(:users) { render json: failed_json, status: 404 }+ on_model_not_found(:users) { render json: failed_json, status: :not_found }endendend@@ -445,14 +447,14 @@ class Admin::UsersController < Admin::StaffControllerenddef sync_sso- return render body: nil, status: 404 unless SiteSetting.enable_discourse_connect+ return render body: nil, status: :not_found unless SiteSetting.enable_discourse_connectbeginsso = DiscourseConnect.parse("sso=#{params[:sso]}&sig=#{params[:sig]}", server_session:)rescue DiscourseConnect::ParseErrorreturn(render json: failed_json.merge(message: I18n.t("discourse_connect.login_error")),- status: 422+ status: :unprocessable_entity)end@@ -461,10 +463,10 @@ class Admin::UsersController < Admin::StaffControllerDiscourseEvent.trigger(:sync_sso, user)render_serialized(user, AdminDetailedUserSerializer, root: false)rescue ActiveRecord::RecordInvalid => ex- render json: failed_json.merge(message: ex.message), status: 403+ render json: failed_json.merge(message: ex.message), status: :forbiddenrescue DiscourseConnect::BlankExternalId => exrender json: failed_json.merge(message: I18n.t("discourse_connect.blank_id_error")),- status: 422+ status: :unprocessable_entityendenddiff --git a/app/controllers/admin/web_hooks_controller.rb b/app/controllers/admin/web_hooks_controller.rbindex 208da2048ae..91232c0ccac 100644--- a/app/controllers/admin/web_hooks_controller.rb+++ b/app/controllers/admin/web_hooks_controller.rb@@ -39,20 +39,20 @@ class Admin::WebHooksController < Admin::AdminControlleradmin_web_hooks_path(limit: limit, offset: offset + limit, format: :json),}- render json: MultiJson.dump(json), status: 200+ render json: MultiJson.dump(json), status: :okenddef showdata = serialize_data(@web_hook, AdminWebHookSerializer, root: "web_hook")web_hook = data.delete("web_hook")data = { "extras" => data, "web_hook" => web_hook }- render json: MultiJson.dump(data), status: 200+ render json: MultiJson.dump(data), status: :okenddef editdata = serialize_data(@web_hook, AdminWebHookSerializer, root: "web_hook")data["extras"] = { "categories" => data.delete(:categories) }- render json: MultiJson.dump(data), status: 200+ render json: MultiJson.dump(data), status: :okenddef create@@ -120,7 +120,7 @@ class Admin::WebHooksController < Admin::AdminController},}- render json: MultiJson.dump(json), status: 200+ render json: MultiJson.dump(json), status: :okenddef bulk_eventsdiff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 1eef09ab3ab..5b43bc5038e 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -29,7 +29,7 @@ class ApplicationController < ActionController::Baseunless is_api? || is_user_api?superclear_current_user- render plain: "[\"BAD CSRF\"]", status: 403+ render plain: "[\"BAD CSRF\"]", status: :forbiddenendend@@ -255,14 +255,16 @@ class ApplicationController < ActionController::Baseformat.json dorender_json_error I18n.t("read_only_mode_enabled"), type: :read_only, status: 503end- format.html { render status: 503, layout: "no_ember", template: "exceptions/read_only" }+ format.html do+ render status: :service_unavailable, layout: "no_ember", template: "exceptions/read_only"+ endendendendrescue_from SecondFactor::AuthManager::SecondFactorRequired do |e|if request.xhr?- render json: { second_factor_challenge_nonce: e.nonce }, status: 403+ render json: { second_factor_challenge_nonce: e.nonce }, status: :forbiddenelseredirect_to session_2fa_path(nonce: e.nonce)enddiff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rbindex d5414fec6f8..2912b929d74 100644--- a/app/controllers/bookmarks_controller.rb+++ b/app/controllers/bookmarks_controller.rb@@ -35,7 +35,8 @@ class BookmarksController < ApplicationControllerreturn render json: success_json.merge(id: bookmark.id) if bookmark_manager.errors.empty?- render json: failed_json.merge(errors: bookmark_manager.errors.full_messages), status: 400+ render json: failed_json.merge(errors: bookmark_manager.errors.full_messages),+ status: :bad_requestenddef destroy@@ -61,7 +62,8 @@ class BookmarksController < ApplicationControllerreturn render json: success_json if bookmark_manager.errors.empty?- render json: failed_json.merge(errors: bookmark_manager.errors.full_messages), status: 400+ render json: failed_json.merge(errors: bookmark_manager.errors.full_messages),+ status: :bad_requestenddef toggle_pin@@ -72,7 +74,8 @@ class BookmarksController < ApplicationControllerreturn render json: success_json if bookmark_manager.errors.empty?- render json: failed_json.merge(errors: bookmark_manager.errors.full_messages), status: 400+ render json: failed_json.merge(errors: bookmark_manager.errors.full_messages),+ status: :bad_requestenddef bulkdiff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rbindex 7dc95e25e26..1ad26c90551 100644--- a/app/controllers/categories_controller.rb+++ b/app/controllers/categories_controller.rb@@ -100,7 +100,7 @@ class CategoriesController < ApplicationControllercategory.move_to(params["position"].to_i)render json: success_jsonelse- render status: 500, json: failed_json+ render status: :internal_server_error, json: failed_jsonendend@@ -143,7 +143,7 @@ class CategoriesController < ApplicationControllerbeginCategory.new(required_create_params.merge(user: current_user))rescue ArgumentError => e- return render json: { errors: [e.message] }, status: 422+ return render json: { errors: [e.message] }, status: :unprocessable_entityendif @category.savediff --git a/app/controllers/drafts_controller.rb b/app/controllers/drafts_controller.rbindex da11cec64d1..a40c57a9520 100644--- a/app/controllers/drafts_controller.rb+++ b/app/controllers/drafts_controller.rb@@ -148,7 +148,7 @@ class DraftsController < ApplicationController# nothing really we can do here, if try clearing a draft that is not ours, just skip it.# rendering an error causes issues in the composerrescue StandardError => e- return render json: failed_json.merge(errors: e), status: 401+ return render json: failed_json.merge(errors: e), status: :unauthorizedendrender json: success_json@@ -191,7 +191,7 @@ class DraftsController < ApplicationControllerfailed_json.merge(errors: "Draft sequence conflict for keys: #{sequence_errors.join(", ")}",),- status: 409+ status: :conflictreturnend@@ -205,7 +205,7 @@ class DraftsController < ApplicationControllerUserStat.update_draft_count(user.id)endrescue StandardError => e- return render json: failed_json.merge(errors: e.message), status: 500+ return render json: failed_json.merge(errors: e.message), status: :internal_server_errorendrender json: success_json.merge(deleted_count: deleted_count)diff --git a/app/controllers/embed_controller.rb b/app/controllers/embed_controller.rbindex b0bd5893997..558ca261478 100644--- a/app/controllers/embed_controller.rb+++ b/app/controllers/embed_controller.rb@@ -16,14 +16,14 @@ class EmbedController < ApplicationController@show_reason = true@hosts = EmbeddableHost.allend- render "embed_error", status: 400+ render "embed_error", status: :bad_requestenddef topicsdiscourse_expires_in 1.minuteunless SiteSetting.embed_topics_list?- render "embed_topics_error", status: 400+ render "embed_topics_error", status: :bad_requestreturnenddiff --git a/app/controllers/export_csv_controller.rb b/app/controllers/export_csv_controller.rbindex 6ce173b1bce..30889fd5267 100644--- a/app/controllers/export_csv_controller.rb+++ b/app/controllers/export_csv_controller.rb@@ -22,7 +22,7 @@ class ExportCsvController < ApplicationControllerunless current_user.admin ||UserExport.where(user_id: entity_id || current_user.id,- created_at: (Time.zone.now.beginning_of_day..Time.zone.now.end_of_day),+ created_at: (Time.zone.now.all_day),).count == 0render_json_error I18n.t("csv_export.rate_limit_error")returndiff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rbindex 61987c111b2..2d1c950e713 100644--- a/app/controllers/forums_controller.rb+++ b/app/controllers/forums_controller.rb@@ -11,9 +11,9 @@ class ForumsController < ActionController::Basedef statusif params[:cluster]if GlobalSetting.cluster_name.nil?- return render plain: "cluster name not configured", status: 500+ return render plain: "cluster name not configured", status: :internal_server_errorelsif GlobalSetting.cluster_name != params[:cluster]- return render plain: "cluster name does not match", status: 500+ return render plain: "cluster name does not match", status: :internal_server_errorendenddiff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rbindex bb34a8e810e..9e0e42e5593 100644--- a/app/controllers/groups_controller.rb+++ b/app/controllers/groups_controller.rb@@ -162,7 +162,7 @@ class GroupsController < ApplicationControlleruser_count = count_existing_users(group.group_users, notification_level, categories, tags)if user_count > 0return(- render status: 422,+ render status: :unprocessable_entity,json: {user_count: user_count,errors: [I18n.t("invalid_params", message: :update_existing_users)],@@ -612,7 +612,7 @@ class GroupsController < ApplicationControllerrescue ActiveRecord::RecordNotUniquereturn(render json: failed_json.merge(error: I18n.t("groups.errors.already_requested_membership")),- status: 409+ status: :conflict)enddiff --git a/app/controllers/inline_onebox_controller.rb b/app/controllers/inline_onebox_controller.rbindex b8e4240a5c4..babd723a80c 100644--- a/app/controllers/inline_onebox_controller.rb+++ b/app/controllers/inline_onebox_controller.rb@@ -9,7 +9,8 @@ class InlineOneboxController < ApplicationControllerurls = params[:urls] || []if urls.size > MAX_URLS_LIMIT- render json: failed_json.merge(errors: [I18n.t("inline_oneboxer.too_many_urls")]), status: 413+ render json: failed_json.merge(errors: [I18n.t("inline_oneboxer.too_many_urls")]),+ status: :payload_too_largereturnend@@ -18,7 +19,7 @@ class InlineOneboxController < ApplicationControllerif InlineOneboxer.is_previewing?(current_user_id)response.headers["Retry-After"] = "60"render json: failed_json.merge(errors: [I18n.t("inline_oneboxer.concurrency_not_allowed")]),- status: 429+ status: :too_many_requestsreturnenddiff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rbindex 19220197694..68f816965c0 100644--- a/app/controllers/invites_controller.rb+++ b/app/controllers/invites_controller.rb@@ -169,7 +169,7 @@ class InvitesController < ApplicationControllershow_warnings: true,)else- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendrescue Invite::UserExists => erender_json_error(e.message)@@ -378,11 +378,14 @@ class InvitesController < ApplicationControllerActiveRecord::RecordNotSaved,ActiveRecord::LockWaitTimeout,Invite::UserExists => e- return render json: failed_json.merge(message: e.message), status: 412+ return render json: failed_json.merge(message: e.message), status: :precondition_failedendif user.blank?- return render json: failed_json.merge(message: I18n.t("invite.not_found_json")), status: 404+ return(+ render json: failed_json.merge(message: I18n.t("invite.not_found_json")),+ status: :not_found+ )endlog_on_user(user) if !redeeming_user && user.active? && user.guardian.can_access_forum?@@ -416,7 +419,7 @@ class InvitesController < ApplicationControllerrender json: success_json.merge(response)else- render json: failed_json.merge(message: I18n.t("invite.not_found_json")), status: 404+ render json: failed_json.merge(message: I18n.t("invite.not_found_json")), status: :not_foundendend@@ -495,7 +498,9 @@ class InvitesController < ApplicationControllerDiscoursePluginRegistry.apply_modifier(:invite_bulk_csv_custom_error, nil, invites)if custom_error.present?- return render json: failed_json.merge(errors: [custom_error]), status: 422+ return(+ render json: failed_json.merge(errors: [custom_error]), status: :unprocessable_entity+ )endJobs.enqueue(:bulk_invite, invites: invites, current_user_id: current_user.id)@@ -510,12 +515,13 @@ class InvitesController < ApplicationController),],),- status: 422+ status: :unprocessable_entityelserender json: success_jsonendelse- render json: failed_json.merge(errors: [I18n.t("bulk_invite.error")]), status: 422+ render json: failed_json.merge(errors: [I18n.t("bulk_invite.error")]),+ status: :unprocessable_entityendendenddiff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rbindex 0de3afb3094..08706302a08 100644--- a/app/controllers/list_controller.rb+++ b/app/controllers/list_controller.rb@@ -430,7 +430,7 @@ class ListController < ApplicationControllerurl = url.sub(ActionController::Base.config.relative_url_root, "")end- return redirect_to path(url), status: 301+ return redirect_to path(url), status: :moved_permanentlyend@description_meta =diff --git a/app/controllers/metadata_controller.rb b/app/controllers/metadata_controller.rbindex b9b2a2978bc..77a71ff8090 100644--- a/app/controllers/metadata_controller.rb+++ b/app/controllers/metadata_controller.rb@@ -8,24 +8,24 @@ class MetadataController < ApplicationController:redirect_to_profile_if_requireddef manifest- expires_in 1.minutes+ expires_in 1.minuterender json: default_manifest.to_json, content_type: "application/manifest+json"enddef opensearch- expires_in 1.minutes+ expires_in 1.minuterender template: "metadata/opensearch", formats: [:xml]enddef app_association_androidraise Discourse::NotFound if SiteSetting.app_association_android.blank?- expires_in 1.minutes+ expires_in 1.minuterender plain: SiteSetting.app_association_android, content_type: "application/json"enddef app_association_iosraise Discourse::NotFound if SiteSetting.app_association_ios.blank?- expires_in 1.minutes+ expires_in 1.minuterender plain: SiteSetting.app_association_ios, content_type: "application/json"enddiff --git a/app/controllers/onebox_controller.rb b/app/controllers/onebox_controller.rbindex 5ccdcd0b9e0..c691876e003 100644--- a/app/controllers/onebox_controller.rb+++ b/app/controllers/onebox_controller.rb@@ -11,7 +11,7 @@ class OneboxController < ApplicationControllerend# only 1 outgoing preview per user- return render(body: nil, status: 429) if Oneboxer.is_previewing?(current_user.id)+ return render(body: nil, status: :too_many_requests) if Oneboxer.is_previewing?(current_user.id)user_id = current_user.idcategory_id = params[:category_id].to_i@@ -19,7 +19,7 @@ class OneboxController < ApplicationControllerinvalidate = params[:refresh] == "true"url = params[:url]- return render(body: nil, status: 404) if Oneboxer.recently_failed?(url)+ return render(body: nil, status: :not_found) if Oneboxer.recently_failed?(url)hijack(info: "#{url} topic_id: #{topic_id} user_id: #{user_id}") doOneboxer.preview_onebox!(user_id)@@ -39,7 +39,7 @@ class OneboxController < ApplicationControllerif preview.blank?Oneboxer.cache_failed!(url)- render body: nil, status: 404+ render body: nil, status: :not_foundelserender plain: previewenddiff --git a/app/controllers/reviewable_notes_controller.rb b/app/controllers/reviewable_notes_controller.rbindex 9c7a199b394..c2a9cf4168c 100644--- a/app/controllers/reviewable_notes_controller.rb+++ b/app/controllers/reviewable_notes_controller.rb@@ -13,7 +13,7 @@ class ReviewableNotesController < ApplicationControllernote.reloadrender json: ReviewableNoteSerializer.new(note, scope: guardian, root: false)else- render json: { errors: note.errors.full_messages }, status: 422+ render json: { errors: note.errors.full_messages }, status: :unprocessable_entityendenddiff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rbindex 1841f269f1b..bd0192dcca0 100644--- a/app/controllers/session_controller.rb+++ b/app/controllers/session_controller.rb@@ -91,14 +91,15 @@ class SessionController < ApplicationControllerrender json: success_json.merge(redirect_url: redirect_url)endrescue DiscourseConnectProvider::BlankSecret- render plain: I18n.t("discourse_connect.missing_secret"), status: 400+ render plain: I18n.t("discourse_connect.missing_secret"), status: :bad_requestrescue DiscourseConnectProvider::ParseError# Do NOT pass the error text to the client, it would give them the correct signature- render plain: I18n.t("discourse_connect.login_error"), status: 422+ render plain: I18n.t("discourse_connect.login_error"), status: :unprocessable_entityrescue DiscourseConnectProvider::BlankReturnUrl- render plain: "return_sso_url is blank, it must be provided", status: 400+ render plain: "return_sso_url is blank, it must be provided", status: :bad_requestrescue DiscourseConnectProvider::InvalidParameterValueError => e- render plain: I18n.t("discourse_connect.invalid_parameter_value", param: e.param), status: 400+ render plain: I18n.t("discourse_connect.invalid_parameter_value", param: e.param),+ status: :bad_requestend# For use in development mode only when login options could be limited or disabled.@@ -110,7 +111,7 @@ class SessionController < ApplicationControllerraise Discourse::InvalidAccess if Rails.env.production?if ENV["DISCOURSE_DEV_ALLOW_ANON_TO_IMPERSONATE"] != "1"- return render plain: <<~TEXT, status: 403+ return render plain: <<~TEXT, status: :forbiddenTo enable impersonating any user without typing passwords set the following ENV varexport DISCOURSE_DEV_ALLOW_ANON_TO_IMPERSONATE=1@@ -122,9 +123,9 @@ class SessionController < ApplicationControlleruser = User.find_by_username(params[:session_id])if user.blank?- return render plain: "User #{params[:session_id]} not found", status: 403+ return render plain: "User #{params[:session_id]} not found", status: :forbiddenelsif !user.active?- return render plain: "User #{params[:session_id]} is not active", status: 403+ return render plain: "User #{params[:session_id]} is not active", status: :forbiddenendlog_on_user(user)@@ -157,7 +158,7 @@ class SessionController < ApplicationController# but since this is a test route, we allow passing a bad value into the API, catch the error# and return a JSON response to assert against.if e.message == "running 2fa against another user is not allowed"- render json: { result: "wrong user" }, status: 400+ render json: { result: "wrong user" }, status: :bad_requestelseraise eend@@ -605,7 +606,7 @@ class SessionController < ApplicationController.deep_symbolize_keys.slice(:ok, :error, :reason).merge(failed_json)- render json: error_json, status: 400+ render json: error_json, status: :bad_requestreturnendend@@ -615,7 +616,7 @@ class SessionController < ApplicationControllercallback_path: challenge[:callback_path],redirect_url: challenge[:redirect_url],},- status: 200+ status: :okenddef forgot_password@@ -661,7 +662,7 @@ class SessionController < ApplicationControllerif current_user.present?render_serialized(current_user, CurrentUserSerializer, { login_method: login_method })else- render body: nil, status: 404+ render body: nil, status: :not_foundendend@@ -716,7 +717,7 @@ class SessionController < ApplicationControllerapi_key = ApiKey.active.with_key(key).firstrender_serialized(api_key.api_key_scopes, ApiKeyScopeSerializer, root: "scopes")else- render body: nil, status: 404+ render body: nil, status: :not_foundendenddiff --git a/app/controllers/sidebar_sections_controller.rb b/app/controllers/sidebar_sections_controller.rbindex 96e823be114..2cffa13589f 100644--- a/app/controllers/sidebar_sections_controller.rb+++ b/app/controllers/sidebar_sections_controller.rb@@ -74,7 +74,7 @@ class SidebarSectionsController < ApplicationControllerrescue ActiveRecord::NestedAttributes::TooManyRecords => erender_json_error(e.message)rescue Discourse::InvalidAccess- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenenddef reset@@ -102,7 +102,7 @@ class SidebarSectionsController < ApplicationControllerrender json: success_jsonrescue Discourse::InvalidAccess- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenenddef section_paramsdiff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rbindex b4f3c6bf724..6c735ccf62a 100644--- a/app/controllers/static_controller.rb+++ b/app/controllers/static_controller.rb@@ -108,7 +108,7 @@ class StaticController < ApplicationControllerend@title = "#{title_prefix} - #{SiteSetting.title}"@body = @topic.posts.first.cooked- @faq_overridden = !SiteSetting.faq_url.blank?+ @faq_overridden = SiteSetting.faq_url.present?@experimental_rename_faq_to_guidelines = rename_faqrender :show, layout: !request.xhr?, formats: [:html]@@ -203,7 +203,7 @@ class StaticController < ApplicationControllerfile&.unlinkendelse- File.read(Rails.root.join("public", favicon.url[1..-1]))+ File.read(Rails.public_path.join(favicon.url[1..-1]))endend@@ -265,7 +265,7 @@ class StaticController < ApplicationControllerrescue Errno::ENOENTexpires_in 1.second, public: true, must_revalidate: false- render plain: "can not find #{params[:path]}", status: 404+ render plain: "can not find #{params[:path]}", status: :not_foundreturnendenddiff --git a/app/controllers/steps_controller.rb b/app/controllers/steps_controller.rbindex 153a2cccfd3..aeed15ca36a 100644--- a/app/controllers/steps_controller.rb+++ b/app/controllers/steps_controller.rb@@ -20,7 +20,7 @@ class StepsController < ApplicationControllerupdater.errors.messages.each do |field, msg|errors << { field: field, description: msg.join }end- render json: { errors: errors }, status: 422+ render json: { errors: errors }, status: :unprocessable_entityendendenddiff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rbindex 7ffd2902c0c..a1a077eec0d 100644--- a/app/controllers/stylesheets_controller.rb+++ b/app/controllers/stylesheets_controller.rb@@ -78,7 +78,7 @@ class StylesheetsController < ApplicationControllerendend- if Rails.env == "development"+ if Rails.env.development?response.headers["Last-Modified"] = Time.zone.now.httpdateimmutable_for(1.second)elsediff --git a/app/controllers/svg_sprite_controller.rb b/app/controllers/svg_sprite_controller.rbindex 48e985be162..1db07800ef0 100644--- a/app/controllers/svg_sprite_controller.rb+++ b/app/controllers/svg_sprite_controller.rb@@ -37,7 +37,7 @@ class SvgSpriteController < ApplicationControllerdata = SvgSprite.search(keyword)if data.blank?- render body: nil, status: 404+ render body: nil, status: :not_foundelserender plain: data.inspect, disposition: nil, content_type: "text/plain"end@@ -62,14 +62,14 @@ class SvgSpriteController < ApplicationControllericon = SvgSprite.search(name)if icon.blank?- render body: nil, status: 404+ render body: nil, status: :not_foundelsedoc = Nokogiri.XML(icon)doc.at_xpath("symbol").name = "svg"doc.at_xpath("svg")["xmlns"] = "http://www.w3.org/2000/svg"doc.at_xpath("svg")["fill"] = adjust_hex(params[:color]) if params[:color]- response.headers["Last-Modified"] = 1.years.ago.httpdate+ response.headers["Last-Modified"] = 1.year.ago.httpdateresponse.headers["Content-Length"] = doc.to_s.bytesize.to_simmutable_for 1.daydiff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rbindex 14dce215d1f..60fd0ce12fb 100644--- a/app/controllers/tags_controller.rb+++ b/app/controllers/tags_controller.rb@@ -267,7 +267,7 @@ class TagsController < ::ApplicationControllerendrender json: success_jsonrescue Discourse::InvalidParameters => e- render json: failed_json.merge(errors: [e.message]), status: 422+ render json: failed_json.merge(errors: [e.message]), status: :unprocessable_entityendendend@@ -328,7 +328,7 @@ class TagsController < ::ApplicationControllerfilter_params[:category] = Category.find_by_id(params[:categoryId]) if params[:categoryId]- if !params[:q].blank?+ if params[:q].present?clean_name = DiscourseTagging.clean_tag(params[:q])filter_params[:term] = clean_namefilter_params[:order_search_results] = true@@ -444,7 +444,7 @@ class TagsController < ::ApplicationControllersynonym.update!(target_tag: nil)render json: success_jsonelse- render json: failed_json, status: 400+ render json: failed_json, status: :bad_requestendenddiff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rbindex d61873c1c06..c2340c23898 100644--- a/app/controllers/topics_controller.rb+++ b/app/controllers/topics_controller.rb@@ -571,7 +571,7 @@ class TopicsController < ApplicationControlleroptions = { by_user: current_user, based_on_last_post: based_on_last_post }- options.merge!(category_id: params[:category_id]) if !params[:category_id].blank?+ options.merge!(category_id: params[:category_id]) if params[:category_id].present?if params[:duration_minutes].present?options.merge!(duration_minutes: params[:duration_minutes].to_i)end@@ -729,7 +729,7 @@ class TopicsController < ApplicationControllerif topic.remove_allowed_user(current_user, user)render json: success_jsonelse- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -741,7 +741,7 @@ class TopicsController < ApplicationControllerif topic.remove_allowed_group(current_user, params[:name])render json: success_jsonelse- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -774,7 +774,7 @@ class TopicsController < ApplicationControllertopic.invite_group(current_user, group, should_notify: should_notify)render_json_dump BasicGroupSerializer.new(group, scope: guardian, root: "group")else- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -827,10 +827,10 @@ class TopicsController < ApplicationControllerendend- render json: json, status: 422+ render json: json, status: :unprocessable_entityendrescue Topic::UserExists, Topic::NotAllowed => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendend@@ -935,7 +935,7 @@ class TopicsController < ApplicationController).change_owner!render json: success_jsonrescue ArgumentError- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -959,7 +959,7 @@ class TopicsController < ApplicationControllerrender json: success_jsonrescue ActiveRecord::RecordInvalid, TopicTimestampChanger::InvalidTimestampError- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -1293,7 +1293,7 @@ class TopicsController < ApplicationControllerurl << "#{s}#{k}=#{v}"end- redirect_to url, status: 301+ redirect_to url, status: :moved_permanentlyenddef track_visit_to_topic@@ -1377,8 +1377,7 @@ class TopicsController < ApplicationControllerhelpers.localize_topic_view_content(@topic_view) if SiteSetting.content_localization_enabled@breadcrumbs = helpers.categories_breadcrumb(@topic_view.topic) || []- @description_meta =- @topic_view.topic.excerpt.present? ? @topic_view.topic.excerpt : @topic_view.summary+ @description_meta = (@topic_view.topic.excerpt.presence || @topic_view.summary)store_preloaded("topic_#{@topic_view.topic.id}", MultiJson.dump(topic_view_serializer))render :showenddiff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rbindex 058f7ecfbf1..092e09a6a83 100644--- a/app/controllers/uploads_controller.rb+++ b/app/controllers/uploads_controller.rb@@ -53,7 +53,7 @@ class UploadsController < ApplicationControllerSiteSetting.discourse_connect_overrides_avatar || SiteSetting.auth_overrides_avatar ||!me.in_any_groups?(SiteSetting.uploaded_avatars_allowed_groups_map))- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityendurl = params[:url]@@ -81,7 +81,8 @@ class UploadsController < ApplicationControllerretain_hours: retain_hours,)rescue => e- render json: failed_json.merge(message: e.message&.split("\n")&.first), status: 422+ render json: failed_json.merge(message: e.message&.split("\n")&.first),+ status: :unprocessable_entityelserender json: UploadsController.serialize_upload(info), status: Upload === info ? 200 : 422enddiff --git a/app/controllers/user_api_keys_controller.rb b/app/controllers/user_api_keys_controller.rbindex 940235baeed..10e77fb662a 100644--- a/app/controllers/user_api_keys_controller.rb+++ b/app/controllers/user_api_keys_controller.rb@@ -87,7 +87,7 @@ class UserApiKeysController < ApplicationControllerapi: AUTH_API_VERSION,}.to_json- public_key_str = @client.public_key.present? ? @client.public_key : params[:public_key]+ public_key_str = (@client.public_key.presence || params[:public_key])public_key = OpenSSL::PKey::RSA.new(public_key_str)# by default, Ruby uses `PKCS1_PADDING` herediff --git a/app/controllers/user_badges_controller.rb b/app/controllers/user_badges_controller.rbindex 84c62d10451..4e83ce5c23e 100644--- a/app/controllers/user_badges_controller.rb+++ b/app/controllers/user_badges_controller.rb@@ -81,7 +81,7 @@ class UserBadgesController < ApplicationControllerparams.require(:username)user = fetch_user_from_params- return render json: failed_json, status: 403 unless can_assign_badge_to_user?(user)+ return render json: failed_json, status: :forbidden unless can_assign_badge_to_user?(user)badge = fetch_badge_from_paramspost_id = nil@@ -90,7 +90,7 @@ class UserBadgesController < ApplicationControllerunless is_badge_reason_valid? params[:reason]return(render json: failed_json.merge(message: I18n.t("invalid_grant_badge_reason_link")),- status: 400+ status: :bad_request)end@@ -120,7 +120,7 @@ class UserBadgesController < ApplicationControlleruser_badge = UserBadge.find(params[:id])unless can_assign_badge_to_user?(user_badge.user)- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenreturnend@@ -133,14 +133,14 @@ class UserBadgesController < ApplicationControlleruser_badge = UserBadge.find(params[:user_badge_id])user_badges = user_badge.user.user_badges- return render json: failed_json, status: 403 unless can_favorite_badge?(user_badge)+ return render json: failed_json, status: :forbidden unless can_favorite_badge?(user_badge)is_favorite = user_badges.where(badge: user_badge.badge, is_favorite: true).exists?if !is_favorite &&user_badges.select(:badge_id).distinct.where(is_favorite: true).count >=SiteSetting.max_favorite_badges- return render json: failed_json, status: 400+ return render json: failed_json, status: :bad_requestendUserBadge.where(user_id: user_badge.user_id, badge_id: user_badge.badge_id).update_all(diff --git a/app/controllers/users/discourse_id_controller.rb b/app/controllers/users/discourse_id_controller.rbindex 3909866fb0b..3ea21a660e9 100644--- a/app/controllers/users/discourse_id_controller.rb+++ b/app/controllers/users/discourse_id_controller.rb@@ -10,11 +10,11 @@ class Users::DiscourseIdController < ApplicationControlleron_success { render json: { success: true } }on_failed_contract do |contract|logger.warn(result.inspect_steps) if SiteSetting.discourse_id_verbose_logging- render json: { error: contract.errors.full_messages.join(", ") }, status: 400+ render json: { error: contract.errors.full_messages.join(", ") }, status: :bad_requestendon_failure dologger.warn(result.inspect_steps) if SiteSetting.discourse_id_verbose_logging- render json: { error: "Invalid request" }, status: 400+ render json: { error: "Invalid request" }, status: :bad_requestendendenddiff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rbindex f144a1be424..5088cd0e212 100644--- a/app/controllers/users/omniauth_callbacks_controller.rb+++ b/app/controllers/users/omniauth_callbacks_controller.rb@@ -104,7 +104,7 @@ class Users::OmniauthCallbacksController < ApplicationControllertrueend- ALLOWED_FAILURE_ERRORS = %w[csrf_detected request_error invalid_iat].to_h { [_1, _1] }+ ALLOWED_FAILURE_ERRORS = %w[csrf_detected request_error invalid_iat].index_by { _1 }def failureerror_name = params[:message].to_s.gsub(/[^\w-]/, "").presencediff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex a52fcd60093..35f4859d636 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -288,7 +288,7 @@ class UsersController < ApplicationControllerif current_user&.staff?render_json_error(I18n.t("errors.messages.auth_overrides_username"))else- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenendend@@ -310,7 +310,7 @@ class UsersController < ApplicationControllerassociated_accounts: user.associated_accounts,}rescue Discourse::InvalidAccess- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenenddef check_sso_email@@ -326,7 +326,7 @@ class UsersController < ApplicationControllerrender json: { email: email }rescue Discourse::InvalidAccess- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenenddef check_sso_payload@@ -342,11 +342,11 @@ class UsersController < ApplicationControllerrender json: { payload: payload }rescue Discourse::InvalidAccess- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenenddef update_primary_email- return render json: failed_json, status: 410 if !SiteSetting.enable_secondary_emails+ return render json: failed_json, status: :gone if !SiteSetting.enable_secondary_emailsparams.require(:email)@@ -359,7 +359,8 @@ class UsersController < ApplicationControllernew_primary = user.user_emails.find_by(email: params[:email])if new_primary.blank?return(- render json: failed_json.merge(errors: [I18n.t("change_email.doesnt_exist")]), status: 428+ render json: failed_json.merge(errors: [I18n.t("change_email.doesnt_exist")]),+ status: :precondition_required)end@@ -379,7 +380,7 @@ class UsersController < ApplicationControllerenddef destroy_email- return render json: failed_json, status: 410 if !SiteSetting.enable_secondary_emails+ return render json: failed_json, status: :gone if !SiteSetting.enable_secondary_emailsparams.require(:email)@@ -392,7 +393,7 @@ class UsersController < ApplicationControllerelsif user.user_emails.where(email: params[:email], primary: false).destroy_all.present?DiscourseEvent.trigger(:user_updated, user)else- return render json: failed_json, status: 428+ return render json: failed_json, status: :precondition_requiredendif current_user.staff? && current_user != user@@ -1075,7 +1076,7 @@ class UsersController < ApplicationControllerlog_on_user(user)render json: success_jsonelse- render json: failed_json, status: 403+ render json: failed_json, status: :forbiddenendend@@ -1324,23 +1325,23 @@ class UsersController < ApplicationControllerguardian.ensure_can_edit!(user)if SiteSetting.discourse_connect_overrides_avatar || SiteSetting.auth_overrides_avatar- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityendtype = params[:type]if type == "gravatar" && !SiteSetting.gravatar_enabled?- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityendinvalid_type = type.present? && !AVATAR_TYPES_WITH_UPLOAD.include?(type) && type != "system"- return render json: failed_json, status: 422 if invalid_type+ return render json: failed_json, status: :unprocessable_entity if invalid_typeif type.blank? || type == "system"upload_id = nilelsif !user.in_any_groups?(SiteSetting.uploaded_avatars_allowed_groups_map) &&!user.is_system_user?- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityelseupload_id = params[:upload_id]upload = Upload.find_by(id: upload_id)@@ -1374,19 +1375,23 @@ class UsersController < ApplicationControllerurl = params[:url]- return render json: failed_json, status: 422 if url.blank?+ return render json: failed_json, status: :unprocessable_entity if url.blank?if SiteSetting.selectable_avatars_mode == "disabled"- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityend- return render json: failed_json, status: 422 if SiteSetting.selectable_avatars.blank?+ if SiteSetting.selectable_avatars.blank?+ return render json: failed_json, status: :unprocessable_entity+ endunless upload = Upload.get_from_url(url)- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityend- return render json: failed_json, status: 422 if SiteSetting.selectable_avatars.exclude?(upload)+ if SiteSetting.selectable_avatars.exclude?(upload)+ return render json: failed_json, status: :unprocessable_entity+ enduser.uploaded_avatar_id = upload.id@@ -1494,7 +1499,7 @@ class UsersController < ApplicationControllerif !SiteSetting.log_search_queriesreturn(render json: failed_json.merge(error: I18n.t("user_activity.no_log_search_queries")),- status: 403+ status: :forbidden)end@@ -1722,7 +1727,7 @@ class UsersController < ApplicationControlleruser_security_key = current_user.security_keys.find_by(id: params[:id].to_i)raise Discourse::InvalidParameters unless user_security_key- user_security_key.update!(name: params[:name]) if params[:name] && !params[:name].blank?+ user_security_key.update!(name: params[:name]) if params[:name] && params[:name].present?user_security_key.update!(enabled: false) if params[:disable] == "true"render json: success_json@@ -1743,7 +1748,7 @@ class UsersController < ApplicationControllerrate_limit_second_factor!(current_user)authenticated =- !auth_token.blank? &&+ auth_token.present? &&totp_object.verify(auth_token,drift_ahead: SecondFactorManager::TOTP_ALLOWED_DRIFT_SECONDS,@@ -1784,7 +1789,7 @@ class UsersController < ApplicationControllerraise Discourse::InvalidParameters unless user_second_factor- user_second_factor.update!(name: params[:name]) if params[:name] && !params[:name].blank?+ user_second_factor.update!(name: params[:name]) if params[:name] && params[:name].present?if params[:disable] == "true"# Disabling backup codes deletes *all* backup codesif update_second_factor_method == UserSecondFactor.methods[:backup_codes]diff --git a/app/controllers/users_email_controller.rb b/app/controllers/users_email_controller.rbindex 7a7dd97144c..f9126bfca2a 100644--- a/app/controllers/users_email_controller.rb+++ b/app/controllers/users_email_controller.rb@@ -18,7 +18,7 @@ class UsersEmailController < ApplicationControllerenddef create- return render json: failed_json, status: 410 if !SiteSetting.enable_secondary_emails+ return render json: failed_json, status: :gone if !SiteSetting.enable_secondary_emailsparams.require(:email)user = fetch_user_from_params@@ -65,7 +65,7 @@ class UsersEmailController < ApplicationControllerupdater.user.user_stat.reset_bounce_score!render json: success_jsonelse- render json: { error: I18n.t("change_email.already_done") }, status: 400+ render json: { error: I18n.t("change_email.already_done") }, status: :bad_requestendendend@@ -89,7 +89,7 @@ class UsersEmailController < ApplicationControllerif updater.confirm(params[:token]) == :authorizing_newrender json: success_jsonelse- render json: { error: I18n.t("change_email.already_done") }, status: 400+ render json: { error: I18n.t("change_email.already_done") }, status: :bad_requestendenddiff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rbindex 85568a01d1d..6495cc13640 100644--- a/app/controllers/webhooks_controller.rb+++ b/app/controllers/webhooks_controller.rb@@ -202,11 +202,11 @@ class WebhooksController < ActionController::Baseprivatedef signature_failure- render body: nil, status: 406+ render body: nil, status: :not_acceptableenddef success- render body: nil, status: 200+ render body: nil, status: :okenddef valid_mailgun_signature?(token, timestamp, signature)diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex d05d9f076dd..44aff8e52f3 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -360,14 +360,7 @@ module ApplicationHelperendprivate def generate_twitter_card_metadata(result, opts)- img_url =- (- if opts[:x_summary_large_image].present?- opts[:x_summary_large_image]- else- opts[:image]- end- )+ img_url = (opts[:x_summary_large_image].presence || opts[:image])# Twitter does not allow SVGs, see https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markupif img_url.ends_with?(".svg")diff --git a/app/helpers/embed_helper.rb b/app/helpers/embed_helper.rbindex 42db197c115..3af784f89aa 100644--- a/app/helpers/embed_helper.rb+++ b/app/helpers/embed_helper.rb@@ -17,7 +17,7 @@ module EmbedHelperdef get_html(post)key = "js.action_codes.#{post.action_code}"- cooked = post.cooked.blank? ? I18n.t(key, when: nil).humanize : post.cooked+ cooked = (post.cooked.presence || I18n.t(key, when: nil).humanize)raw PrettyText.format_for_email(cooked, post)enddiff --git a/app/jobs/base.rb b/app/jobs/base.rbindex 1dd7138f040..16fa6f1ccfc 100644--- a/app/jobs/base.rb+++ b/app/jobs/base.rb@@ -423,7 +423,7 @@ module JobsDB.after_commit { klass.client_push(hash) }else- if Rails.env == "development"+ if Rails.env.development?Scheduler::Defer.later("job") { klass.new.perform(opts) }else# Run the job synchronouslydiff --git a/app/jobs/concerns/skippable.rb b/app/jobs/concerns/skippable.rbindex dfc6adf2231..bb2e0bd2c24 100644--- a/app/jobs/concerns/skippable.rb+++ b/app/jobs/concerns/skippable.rb@@ -15,9 +15,7 @@ module Skippableif reason_type == SkippedEmailLog.reason_types[:exceeded_emails_limit]exists =SkippedEmailLog.exists?(- { created_at: (Time.zone.now.beginning_of_day..Time.zone.now.end_of_day) }.merge!(- attributes.except(:post_id),- ),+ { created_at: (Time.zone.now.all_day) }.merge!(attributes.except(:post_id)),)return if existsdiff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rbindex d532f4f2c51..20bca4d3e23 100644--- a/app/jobs/regular/export_csv_file.rb+++ b/app/jobs/regular/export_csv_file.rb@@ -11,7 +11,7 @@ module Jobsattr_accessor :entityHEADER_ATTRS_FOR =- HashWithIndifferentAccess.new(+ ActiveSupport::HashWithIndifferentAccess.new(user_list: %w[idname@@ -60,7 +60,7 @@ module Jobsdef execute(args)@entity = args[:entity]- @extra = HashWithIndifferentAccess.new(args[:args]) if args[:args]+ @extra = ActiveSupport::HashWithIndifferentAccess.new(args[:args]) if args[:args]@current_user = User.find_by(id: args[:user_id])entity = { name: @entity }diff --git a/app/jobs/regular/export_user_archive.rb b/app/jobs/regular/export_user_archive.rbindex b1697c8dd9a..f5480010dcf 100644--- a/app/jobs/regular/export_user_archive.rb+++ b/app/jobs/regular/export_user_archive.rb@@ -26,7 +26,7 @@ module Jobs]HEADER_ATTRS_FOR =- HashWithIndifferentAccess.new(+ ActiveSupport::HashWithIndifferentAccess.new(user_archive: %w[topic_titlecategories@@ -130,7 +130,7 @@ module Jobs@requesting_user = @archive_for_userend- @extra = HashWithIndifferentAccess.new(args[:args]) if args[:args]+ @extra = ActiveSupport::HashWithIndifferentAccess.new(args[:args]) if args[:args]@timestamp ||= Time.now.strftime("%y%m%d-%H%M%S")components = []diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rbindex 467af7cff79..ef81bf9ce28 100644--- a/app/jobs/regular/notify_mailing_list_subscribers.rb+++ b/app/jobs/regular/notify_mailing_list_subscribers.rb@@ -4,7 +4,15 @@ module Jobsclass NotifyMailingListSubscribers < ::Jobs::Baseinclude Skippable- RETRY_TIMES = [5.minute, 15.minute, 30.minute, 45.minute, 90.minute, 180.minute, 300.minute]+ RETRY_TIMES = [+ 5.minutes,+ 15.minutes,+ 30.minutes,+ 45.minutes,+ 90.minutes,+ 180.minutes,+ 300.minutes,+ ]sidekiq_options queue: "low"diff --git a/app/jobs/regular/pull_hotlinked_images.rb b/app/jobs/regular/pull_hotlinked_images.rbindex 233c1144aad..d27f4180a50 100644--- a/app/jobs/regular/pull_hotlinked_images.rb+++ b/app/jobs/regular/pull_hotlinked_images.rb@@ -24,7 +24,7 @@ module Jobspost = Post.find_by(id: @post_id)return if post.nil? || post.topic.nil?- hotlinked_map = post.post_hotlinked_media.map { |r| [r.url, r] }.to_h+ hotlinked_map = post.post_hotlinked_media.index_by { |r| r.url }changed_hotlink_records = falsediff --git a/app/jobs/regular/update_hotlinked_raw.rb b/app/jobs/regular/update_hotlinked_raw.rbindex 3763ab96a61..b9432b6cbbc 100644--- a/app/jobs/regular/update_hotlinked_raw.rb+++ b/app/jobs/regular/update_hotlinked_raw.rb@@ -13,7 +13,7 @@ module Jobsreturn if post.cook_method == Post.cook_methods[:raw_html]return if post.topic.nil?- hotlinked_map = post.post_hotlinked_media.preload(:upload).map { |r| [r.url, r] }.to_h+ hotlinked_map = post.post_hotlinked_media.preload(:upload).index_by { |r| r.url }raw =InlineUploads.replace_hotlinked_image_urls(raw: post.raw) do |match_src|diff --git a/app/jobs/scheduled/aggregate_web_hooks_events.rb b/app/jobs/scheduled/aggregate_web_hooks_events.rbindex 856cbde059f..825dca90b59 100644--- a/app/jobs/scheduled/aggregate_web_hooks_events.rb+++ b/app/jobs/scheduled/aggregate_web_hooks_events.rb@@ -5,7 +5,7 @@ module Jobsevery 1.daydef execute(args = {})- date = args[:date].present? ? args[:date] : Time.zone.now.to_date+ date = (args[:date].presence || Time.zone.now.to_date)WebHook.joins("LEFT JOIN web_hook_events_daily_aggregates ON web_hooks.id = web_hook_events_daily_aggregates.web_hook_id AND web_hook_events_daily_aggregates.date = '#{date}'",diff --git a/app/jobs/scheduled/cleanup_redelivering_web_hook_events.rb b/app/jobs/scheduled/cleanup_redelivering_web_hook_events.rbindex 9e290e1f40b..27e04aacba3 100644--- a/app/jobs/scheduled/cleanup_redelivering_web_hook_events.rb+++ b/app/jobs/scheduled/cleanup_redelivering_web_hook_events.rb@@ -9,7 +9,7 @@ module Jobsdef execute(args)RedeliveringWebhookEvent.includes(web_hook_event: :web_hook)- .where("created_at < ?", 8.hour.ago)+ .where("created_at < ?", 8.hours.ago).delete_allendenddiff --git a/app/jobs/scheduled/old_keys_reminder.rb b/app/jobs/scheduled/old_keys_reminder.rbindex cec2108b542..1adef8c59bb 100644--- a/app/jobs/scheduled/old_keys_reminder.rb+++ b/app/jobs/scheduled/old_keys_reminder.rb@@ -67,9 +67,11 @@ module Jobsdef keys_listmessages =- old_site_settings_keys.map { |key| "#{key.name} - #{key.updated_at.to_date.to_fs(:db)}" }+ old_site_settings_keys.map do |key|+ "#{key.name} - #{key.updated_at.to_date.to_formatted_s(:db)}"+ endold_api_keys.each_with_object(messages) do |key, array|- array << "#{[key.description, key.user&.username, key.created_at.to_date.to_fs(:db)].compact.join(" - ")}"+ array << "#{[key.description, key.user&.username, key.created_at.to_date.to_formatted_s(:db)].compact.join(" - ")}"endmessages.join("\n")enddiff --git a/app/jobs/scheduled/update_topic_hot_scores.rb b/app/jobs/scheduled/update_topic_hot_scores.rbindex c9eecedc1a5..d03f3a1d1ff 100644--- a/app/jobs/scheduled/update_topic_hot_scores.rb+++ b/app/jobs/scheduled/update_topic_hot_scores.rb@@ -8,7 +8,7 @@ module Jobsdef execute(args)if SiteSetting.top_menu_map.include?("hot") ||- Discourse.redis.set(HOT_SCORE_UPDATE_REDIS_KEY, 1, ex: 6.hour, nx: true)+ Discourse.redis.set(HOT_SCORE_UPDATE_REDIS_KEY, 1, ex: 6.hours, nx: true)TopicHotScore.update_scoresendenddiff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rbindex d057c5c3420..52f862f4f97 100644--- a/app/mailers/user_notifications.rb+++ b/app/mailers/user_notifications.rb@@ -75,7 +75,7 @@ class UserNotifications < ActionMailer::Basetemplate: "user_notifications.suspicious_login",locale: user_locale(user),client_ip: opts[:client_ip],- location: location.present? ? location : I18n.t("staff_action_logs.unknown"),+ location: (location.presence || I18n.t("staff_action_logs.unknown")),browser: I18n.t("user_auth_tokens.browser.#{browser}"),device: I18n.t("user_auth_tokens.device.#{device}"),os: I18n.t("user_auth_tokens.os.#{os}"),diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rbindex 77bf88606e9..52e98a0924f 100644--- a/app/models/api_key_scope.rb+++ b/app/models/api_key_scope.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueclass ApiKeyScope < ActiveRecord::Base- validates_presence_of :resource- validates_presence_of :action+ validates :resource, presence: true+ validates :action, presence: trueclass << selfdef list_actionsdiff --git a/app/models/application_request.rb b/app/models/application_request.rbindex 9b605493423..ba93f5a1913 100644--- a/app/models/application_request.rb+++ b/app/models/application_request.rb@@ -48,7 +48,7 @@ class ApplicationRequest < ActiveRecord::Baseenddef self.stats- s = HashWithIndifferentAccess.new({})+ s = ActiveSupport::HashWithIndifferentAccess.new({})self.req_types.each do |key, i|query = self.where(req_type: i)diff --git a/app/models/badge.rb b/app/models/badge.rbindex 3ee34bd60df..03a595cd4dd 100644--- a/app/models/badge.rb+++ b/app/models/badge.rb@@ -121,8 +121,8 @@ class Badge < ActiveRecord::Basescope :enabled, -> { where(enabled: true) }- before_create :ensure_not_systembefore_save :sanitize_description+ before_create :ensure_not_systemafter_save doif saved_change_to_image_upload_id?diff --git a/app/models/category.rb b/app/models/category.rbindex 7c48540a669..12fb6340ea0 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -107,15 +107,22 @@ class Category < ActiveRecord::Basevalidates :color, format: { with: /\A(\h{6}|\h{3})\z/ }validates :text_color, format: { with: /\A(\h{6}|\h{3})\z/ }- after_create :create_category_definition- after_destroy :trash_category_definition- after_destroy :clear_related_site_settings-before_save :apply_permissionsbefore_save :downcase_emailbefore_save :downcase_namebefore_save :ensure_category_setting+ after_create :create_category_definition+ after_create :delete_category_permalink+ after_update :rename_category_definition, if: :saved_change_to_name?+ after_update :create_category_permalink, if: :saved_change_to_slug?+ after_update :run_plugin_category_update_param_callbacks+ after_destroy :trash_category_definition+ after_destroy :clear_related_site_settings+ after_destroy :reset_topic_ids_cache+ after_destroy :clear_subcategory_ids+ after_destroy :publish_category_deletion+ after_destroy :remove_site_settingsafter_save :reset_topic_ids_cacheafter_save :clear_subcategory_idsafter_save :clear_url_cache@@ -135,17 +142,6 @@ class Category < ActiveRecord::Baseendend- after_destroy :reset_topic_ids_cache- after_destroy :clear_subcategory_ids- after_destroy :publish_category_deletion- after_destroy :remove_site_settings-- after_create :delete_category_permalink-- after_update :rename_category_definition, if: :saved_change_to_name?- after_update :create_category_permalink, if: :saved_change_to_slug?- after_update :run_plugin_category_update_param_callbacks-after_commit :trigger_category_created_event, on: :createafter_commit :trigger_category_updated_event, on: :updateafter_commit :trigger_category_destroyed_event, on: :destroy@@ -638,7 +634,7 @@ class Category < ActiveRecord::Basedef topic_urlif has_attribute?("topic_slug")- Topic.relative_url(topic_id, read_attribute(:topic_slug))+ Topic.relative_url(topic_id, self[:topic_slug])elsetopic_only_relative_url.try(:relative_url)enddiff --git a/app/models/category_user.rb b/app/models/category_user.rbindex d7cee509c71..22232a7fb3c 100644--- a/app/models/category_user.rb+++ b/app/models/category_user.rb@@ -228,9 +228,7 @@ class CategoryUser < ActiveRecord::Baseenddef self.create_lookup(category_users)- category_users.each_with_object({}) do |category_user, acc|- acc[category_user.category_id] = category_user- end+ category_users.index_by(&:category_id)enddef self.muted_category_ids_query(user, include_direct: false)diff --git a/app/models/concerns/has_custom_fields.rb b/app/models/concerns/has_custom_fields.rbindex f763b7278c1..b3b3121ad53 100644--- a/app/models/concerns/has_custom_fields.rb+++ b/app/models/concerns/has_custom_fields.rb@@ -346,7 +346,7 @@ module HasCustomFieldsprotecteddef refresh_custom_fields_from_db- target = HashWithIndifferentAccess.new+ target = ActiveSupport::HashWithIndifferentAccess.new_custom_fields.order(:id).pluck(:name, :value)diff --git a/app/models/concerns/has_search_data.rb b/app/models/concerns/has_search_data.rbindex 1ff9a16358d..f96b4106022 100644--- a/app/models/concerns/has_search_data.rb+++ b/app/models/concerns/has_search_data.rb@@ -7,6 +7,6 @@ module HasSearchData_associated_record_name = self.name.sub("SearchData", "").underscoreself.primary_key = "#{_associated_record_name}_id"belongs_to _associated_record_name.to_sym- validates_presence_of :search_data+ validates :search_data, presence: trueendenddiff --git a/app/models/concerns/second_factor_manager.rb b/app/models/concerns/second_factor_manager.rbindex f0a1018d88a..438b9e66eb9 100644--- a/app/models/concerns/second_factor_manager.rb+++ b/app/models/concerns/second_factor_manager.rb@@ -46,7 +46,7 @@ module SecondFactorManagerlast_used = totp.last_used.to_i if totp.last_usedauthenticated =- !token.blank? &&+ token.present? &&totp.totp_object.verify(token,drift_ahead: TOTP_ALLOWED_DRIFT_SECONDS,@@ -243,7 +243,7 @@ module SecondFactorManagerenddef authenticate_backup_code(backup_code)- if !backup_code.blank?+ if backup_code.present?codes = self.user_second_factors&.backup_codescodes.each do |code|diff --git a/app/models/developer.rb b/app/models/developer.rbindex 458602c1341..0460ca4a57d 100644--- a/app/models/developer.rb+++ b/app/models/developer.rb@@ -3,8 +3,8 @@class Developer < ActiveRecord::Basebelongs_to :user- after_save :rebuild_cacheafter_destroy :rebuild_cache+ after_save :rebuild_cachedef self.id_cache@id_cache ||= DistributedCache.new("developer_ids")diff --git a/app/models/discourse_connect.rb b/app/models/discourse_connect.rbindex ae50103d677..06ff49d6e3b 100644--- a/app/models/discourse_connect.rb+++ b/app/models/discourse_connect.rb@@ -349,7 +349,7 @@ class DiscourseConnect < DiscourseConnectBaseendif SiteSetting.auth_overrides_name && user.name != name && name.present?- user.name = name || User.suggest_name(username.blank? ? email : username)+ user.name = name || User.suggest_name(username.presence || email)endif locale_force_update && SiteSetting.allow_user_locale && locale.present? &&diff --git a/app/models/global_setting.rb b/app/models/global_setting.rbindex c8cd6845c15..490c5b9e38e 100644--- a/app/models/global_setting.rb+++ b/app/models/global_setting.rb@@ -45,7 +45,7 @@ class GlobalSettingendendend- if !secret_key_base.blank? && token != secret_key_base+ if secret_key_base.present? && token != secret_key_baseSTDERR.puts "WARNING: DISCOURSE_SECRET_KEY_BASE is invalid, it was re-generated"endtoken@@ -219,7 +219,7 @@ class GlobalSettingc[:username] = redis_username if redis_username.present?c[:password] = redis_password if redis_password.present?c[:db] = redis_db if redis_db != 0- c[:db] = 1 if Rails.env == "test"+ c[:db] = 1 if Rails.env.test?c[:id] = nil if redis_skip_client_commandsc[:ssl] = true if redis_use_ssl@@ -246,7 +246,7 @@ class GlobalSettingc[:username] = message_bus_redis_username if message_bus_redis_username.present?c[:password] = message_bus_redis_password if message_bus_redis_password.present?c[:db] = message_bus_redis_db if message_bus_redis_db != 0- c[:db] = 1 if Rails.env == "test"+ c[:db] = 1 if Rails.env.test?c[:id] = nil if message_bus_redis_skip_client_commandsc[:ssl] = true if redis_use_ssl@@ -293,13 +293,7 @@ class GlobalSettingenddef resolve(current, default)- BaseProvider.coerce(- if current.present?- current- else- default.present? ? default : nil- end,- )+ BaseProvider.coerce(current.presence || default.presence)endend@@ -373,7 +367,7 @@ class GlobalSettingenddef self.configure!- if Rails.env == "test"+ if Rails.env.test?@provider = BlankProvider.newelse@provider =diff --git a/app/models/group.rb b/app/models/group.rbindex af656178b8a..f40ee8120b1 100644--- a/app/models/group.rb+++ b/app/models/group.rb@@ -50,6 +50,8 @@ class Group < ActiveRecord::Basebefore_save :downcase_incoming_emailbefore_save :cook_bio+ before_destroy :cache_group_users_for_destroyed_event, prepend: true+ after_destroy :expire_cacheafter_save :destroy_deletionsafter_save :update_primary_groupafter_save :update_title@@ -64,12 +66,10 @@ class Group < ActiveRecord::Baseendafter_save :expire_cache- after_destroy :expire_cacheafter_commit :automatic_group_membership, on: %i[create update]after_commit :trigger_group_created_event, on: :createafter_commit :trigger_group_updated_event, on: :update- before_destroy :cache_group_users_for_destroyed_event, prepend: trueafter_commit :trigger_group_destroyed_event, on: :destroyafter_commit :set_default_notifications, on: %i[create update]@@ -348,7 +348,7 @@ class Group < ActiveRecord::Baseenddef smtp_from_address- self.email_from_alias.present? ? self.email_from_alias : self.email_username+ email_from_alias.presence || email_usernameenddef downcase_incoming_emaildiff --git a/app/models/group_associated_group.rb b/app/models/group_associated_group.rbindex 4e9f963fbd1..893af1a1331 100644--- a/app/models/group_associated_group.rb+++ b/app/models/group_associated_group.rb@@ -3,8 +3,8 @@ class GroupAssociatedGroup < ActiveRecord::Basebelongs_to :groupbelongs_to :associated_group- after_commit :add_associated_users, on: %i[create update]before_destroy :remove_associated_users+ after_commit :add_associated_users, on: %i[create update]def add_associated_userswith_mutex dodiff --git a/app/models/group_history.rb b/app/models/group_history.rbindex 016306738dd..7d0de240759 100644--- a/app/models/group_history.rb+++ b/app/models/group_history.rb@@ -31,7 +31,7 @@ class GroupHistory < ActiveRecord::Base.where(group_id: group.id).order("group_histories.created_at DESC")- if !params.blank?+ if params.present?params = params.slice(*filters)records = records.where(action: self.actions[params[:action].to_sym]) if params[:actiondiff --git a/app/models/group_user.rb b/app/models/group_user.rbindex 2030f291b97..86ef4f65601 100644--- a/app/models/group_user.rb+++ b/app/models/group_user.rb@@ -4,13 +4,13 @@ class GroupUser < ActiveRecord::Basebelongs_to :groupbelongs_to :user- after_save :update_title+ before_create :set_notification_levelafter_destroy :grant_other_available_title+ after_destroy :remove_primary_and_flair_group, :recalculate_trust_level+ after_save :update_titleafter_save :set_primary_group- after_destroy :remove_primary_and_flair_group, :recalculate_trust_level- before_create :set_notification_levelafter_save :grant_trust_levelafter_save :set_category_notificationsafter_save :set_tag_notificationsdiff --git a/app/models/invite.rb b/app/models/invite.rbindex f76b0512cd0..83d3c4b42be 100644--- a/app/models/invite.rb+++ b/app/models/invite.rb@@ -31,7 +31,7 @@ class Invite < ActiveRecord::Basehas_many :topic_inviteshas_many :topics, through: :topic_invites, source: :topic- validates_presence_of :invited_by_id+ validates :invited_by_id, presence: truevalidates :email, email: true, allow_blank: truevalidates :custom_message, length: { maximum: 1000 }validates :domain, length: { maximum: 500 }diff --git a/app/models/invited_user.rb b/app/models/invited_user.rbindex efb994372f5..1f0cff1b757 100644--- a/app/models/invited_user.rb+++ b/app/models/invited_user.rb@@ -4,8 +4,8 @@ class InvitedUser < ActiveRecord::Basebelongs_to :userbelongs_to :invite, -> { unscope(where: :deleted_at) }- validates_presence_of :invite_id- validates_uniqueness_of :invite_id, scope: :user_id, conditions: -> { where.not(user_id: nil) }+ validates :invite_id, presence: true+ validates :invite_id, uniqueness: { scope: :user_id, conditions: -> { where.not(user_id: nil) } }end# == Schema Informationdiff --git a/app/models/notification.rb b/app/models/notification.rbindex 1d5cc9e08c1..8857ad7e731 100644--- a/app/models/notification.rb+++ b/app/models/notification.rb@@ -11,8 +11,8 @@ class Notification < ActiveRecord::BaseMEMBERSHIP_REQUEST_CONSOLIDATION_WINDOW_HOURS = 24- validates_presence_of :data- validates_presence_of :notification_type+ validates :data, presence: true+ validates :notification_type, presence: truescope :unread, lambda { where(read: false) }scope :recent,diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rbindex 84722c8c2b0..08a8c65ac30 100644--- a/app/models/optimized_image.rb+++ b/app/models/optimized_image.rb@@ -178,7 +178,7 @@ class OptimizedImage < ActiveRecord::Baseelsesize = calculate_filesize- write_attribute(:filesize, size)+ self[:filesize] = sizeupdate_columns(filesize: size) if !new_record?sizeenddiff --git a/app/models/post.rb b/app/models/post.rbindex 2c3148b7385..8cbed1e6eec 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -1051,7 +1051,7 @@ class Post < ActiveRecord::Basepost_revision = PostRevision.find_by(post_id: id, number: (number + 1))post_revision.modifications.each do |attribute, change|attribute = "version" if attribute == "cached_version"- write_attribute(attribute, change[0])+ self[attribute] = change[0]endend@@ -1342,7 +1342,7 @@ class Post < ActiveRecord::Basedef parse_quote_into_arguments(quote)return {} if quote.blank?- args = HashWithIndifferentAccess.new+ args = ActiveSupport::HashWithIndifferentAccess.newquote.first.scan(/([a-z]+)\:(\d+)/).each { |arg| args[arg[0]] = arg[1].to_i }argsenddiff --git a/app/models/post_detail.rb b/app/models/post_detail.rbindex c28d501d8ec..d23b74bdd5f 100644--- a/app/models/post_detail.rb+++ b/app/models/post_detail.rb@@ -3,8 +3,8 @@class PostDetail < ActiveRecord::Basebelongs_to :post- validates_presence_of :key, :value- validates_uniqueness_of :key, scope: :post_id+ validates :key, :value, presence: true+ validates :key, uniqueness: { scope: :post_id }end# == Schema Informationdiff --git a/app/models/post_reply.rb b/app/models/post_reply.rbindex d2cce1de360..e856501b063 100644--- a/app/models/post_reply.rb+++ b/app/models/post_reply.rb@@ -4,7 +4,7 @@ class PostReply < ActiveRecord::Basebelongs_to :postbelongs_to :reply, foreign_key: :reply_post_id, class_name: "Post"- validates_uniqueness_of :reply_post_id, scope: :post_id+ validates :reply_post_id, uniqueness: { scope: :post_id }validate :ensure_same_topicprivatediff --git a/app/models/post_timing.rb b/app/models/post_timing.rbindex 69d74dacc76..5d9d09b6753 100644--- a/app/models/post_timing.rb+++ b/app/models/post_timing.rb@@ -4,8 +4,8 @@ class PostTiming < ActiveRecord::Basebelongs_to :topicbelongs_to :user- validates_presence_of :post_number- validates_presence_of :msecs+ validates :post_number, presence: true+ validates :msecs, presence: truedef self.pretend_read(topic_id, actual_read_post_number, pretend_read_post_number, user_ids = nil)# This is done in SQL cause the logic is quite tricky and we want to do this in one db hitdiff --git a/app/models/published_page.rb b/app/models/published_page.rbindex 5fd47bb9236..49fc1df7417 100644--- a/app/models/published_page.rb+++ b/app/models/published_page.rb@@ -3,8 +3,8 @@class PublishedPage < ActiveRecord::Basebelongs_to :topic- validates_presence_of :slug- validates_uniqueness_of :slug, :topic_id+ validates :slug, presence: true+ validates :slug, :topic_id, uniqueness: truevalidate :slug_formatdef slug_formatdiff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rbindex bdd9e1b53d7..bdfe9661bf5 100644--- a/app/models/remote_theme.rb+++ b/app/models/remote_theme.rb@@ -40,10 +40,12 @@ class RemoteTheme < ActiveRecord::Base)end- validates_format_of :minimum_discourse_version,- :maximum_discourse_version,- with: Discourse::VERSION_REGEXP,- allow_nil: true+ validates :minimum_discourse_version,+ :maximum_discourse_version,+ format: {+ with: Discourse::VERSION_REGEXP,+ allow_nil: true,+ }def self.extract_theme_info(importer)if importer.file_size("about.json") > MAX_METADATA_FILE_SIZEdiff --git a/app/models/reviewable.rb b/app/models/reviewable.rbindex d9241cfeada..fd16527b53c 100644--- a/app/models/reviewable.rb+++ b/app/models/reviewable.rb@@ -22,7 +22,7 @@ class Reviewable < ActiveRecord::Baseendattr_accessor :created_new- validates_presence_of :type, :status, :created_by_id+ validates :type, :status, :created_by_id, presence: truebelongs_to :target, polymorphic: truebelongs_to :created_by, class_name: "User"belongs_to :target_created_by, class_name: "User"diff --git a/app/models/reviewable_claimed_topic.rb b/app/models/reviewable_claimed_topic.rbindex e9e9d941ef0..56512813846 100644--- a/app/models/reviewable_claimed_topic.rb+++ b/app/models/reviewable_claimed_topic.rb@@ -3,7 +3,7 @@class ReviewableClaimedTopic < ActiveRecord::Basebelongs_to :topicbelongs_to :user- validates_uniqueness_of :topic+ validates :topic, uniqueness: truedef self.claimed_hash(topic_ids)result = {}diff --git a/app/models/search_log.rb b/app/models/search_log.rbindex 86cc0761e70..cedd937d686 100644--- a/app/models/search_log.rb+++ b/app/models/search_log.rb@@ -3,7 +3,7 @@class SearchLog < ActiveRecord::BaseMAXIMUM_USER_AGENT_LENGTH = 2000- validates_presence_of :term+ validates :term, presence: truevalidates :user_agent, length: { maximum: MAXIMUM_USER_AGENT_LENGTH }belongs_to :userdiff --git a/app/models/site_setting.rb b/app/models/site_setting.rbindex 7fecb3a03bd..4b4a3c24285 100644--- a/app/models/site_setting.rb+++ b/app/models/site_setting.rb@@ -75,8 +75,8 @@ class SiteSetting < ActiveRecord::Basehas_many :upload_references, as: :target, dependent: :destroy- validates_presence_of :name- validates_presence_of :data_type+ validates :name, presence: true+ validates :data_type, presence: trueafter_save doif saved_change_to_value?diff --git a/app/models/tag_group.rb b/app/models/tag_group.rbindex b8c61724ef2..d79d5270efb 100644--- a/app/models/tag_group.rb+++ b/app/models/tag_group.rb@@ -2,7 +2,7 @@class TagGroup < ActiveRecord::Basevalidates :name, length: { maximum: 100 }- validates_uniqueness_of :name, case_sensitive: false+ validates :name, uniqueness: { case_sensitive: false }has_many :tag_group_memberships, dependent: :destroyhas_many :tags, through: :tag_group_memberships@@ -17,9 +17,9 @@ class TagGroup < ActiveRecord::Basebelongs_to :parent_tag, class_name: "Tag"- before_create :init_permissionsbefore_save :apply_permissionsbefore_save :remove_parent_from_group+ before_create :init_permissionsafter_commit { DiscourseTagging.clear_cache! }diff --git a/app/models/theme_modifier_set.rb b/app/models/theme_modifier_set.rbindex bff4604deb7..35afc214bdc 100644--- a/app/models/theme_modifier_set.rb+++ b/app/models/theme_modifier_set.rb@@ -13,7 +13,7 @@ class ThemeModifierSet < ActiveRecord::Basedef type_validatorThemeModifierSet.modifiers.each do |k, config|- value = read_attribute(k)+ value = self[k]next if value.nil?case config[:type]@@ -92,8 +92,8 @@ class ThemeModifierSet < ActiveRecord::Basevalue =target_setting_name.present? ? target_setting_value : theme.settings[setting_name]&.valuevalue = coerce_setting_value(modifier_name, value)- if read_attribute(modifier_name) != value- write_attribute(modifier_name, value)+ if self[modifier_name] != value+ self[modifier_name] = valuechanged = trueendenddiff --git a/app/models/theme_setting.rb b/app/models/theme_setting.rbindex cabfbc54f89..3c61fcb280c 100644--- a/app/models/theme_setting.rb+++ b/app/models/theme_setting.rb@@ -10,13 +10,13 @@ class ThemeSetting < ActiveRecord::BaseMAXIMUM_JSON_VALUE_SIZE_BYTES = 0.5 * 1024 * 1024 # 0.5 MB- validates_presence_of :name, :theme+ validates :name, :theme, presence: truevalidates :data_type, inclusion: { in: TYPES_ENUM.values }validate :json_value_size, if: -> { self.data_type == TYPES_ENUM[:objects] }validates :name, length: { maximum: 255 }- after_save :clear_settings_cacheafter_destroy :clear_settings_cache+ after_save :clear_settings_cacheafter_save doif self.data_type == ThemeSetting.types[:upload] && saved_change_to_value?diff --git a/app/models/topic.rb b/app/models/topic.rbindex f0239cb295f..4fcc1e68542 100644--- a/app/models/topic.rb+++ b/app/models/topic.rb@@ -408,7 +408,7 @@ class Topic < ActiveRecord::Basebefore_save doensure_topic_has_a_category unless skip_callbacks- write_attribute(:fancy_title, Topic.fancy_title(title)) if title_changed?+ self[:fancy_title] = Topic.fancy_title(title) if title_changed?if category_id_changed? || new_record?inherit_auto_close_from_category@@ -537,7 +537,7 @@ class Topic < ActiveRecord::Baseunless fancy_title = read_attribute(:fancy_title)fancy_title = Topic.fancy_title(title)- write_attribute(:fancy_title, fancy_title)+ self[:fancy_title] = fancy_titleif !new_record? && !Discourse.readonly_mode?# make sure data is set in table, this also allows us to change algorithm@@ -1461,7 +1461,7 @@ class Topic < ActiveRecord::Basereturn "" if title.blank?slug = slug_for_topic(title)if new_record?- write_attribute(:slug, slug)+ self[:slug] = slugelseupdate_column(:slug, slug)end@@ -1481,8 +1481,8 @@ class Topic < ActiveRecord::Basedef title=(t)slug = slug_for_topic(t.to_s)- write_attribute(:slug, slug)- write_attribute(:fancy_title, nil)+ self[:slug] = slug+ self[:fancy_title] = nilwrite_attribute(:title, t)end@@ -1664,7 +1664,7 @@ class Topic < ActiveRecord::Basetopic_timer.status_type = status_typetime_now = Time.zone.now- topic_timer.based_on_last_post = !based_on_last_post.blank?+ topic_timer.based_on_last_post = based_on_last_post.present?if status_type == TopicTimer.types[:publish_to_category]topic_timer.category = Category.find_by(id: category_id)diff --git a/app/models/topic_allowed_group.rb b/app/models/topic_allowed_group.rbindex d5ee5e5d63d..531ab354380 100644--- a/app/models/topic_allowed_group.rb+++ b/app/models/topic_allowed_group.rb@@ -4,7 +4,7 @@ class TopicAllowedGroup < ActiveRecord::Basebelongs_to :topicbelongs_to :group- validates_uniqueness_of :topic_id, scope: :group_id+ validates :topic_id, uniqueness: { scope: :group_id }end# == Schema Informationdiff --git a/app/models/topic_allowed_user.rb b/app/models/topic_allowed_user.rbindex cc497d1a842..e1aeb740f11 100644--- a/app/models/topic_allowed_user.rb+++ b/app/models/topic_allowed_user.rb@@ -4,7 +4,7 @@ class TopicAllowedUser < ActiveRecord::Basebelongs_to :topicbelongs_to :user- validates_uniqueness_of :topic_id, scope: :user_id+ validates :topic_id, uniqueness: { scope: :user_id }end# == Schema Informationdiff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rbindex 2959a76e933..7d1aa6bcde8 100644--- a/app/models/topic_embed.rb+++ b/app/models/topic_embed.rb@@ -7,8 +7,8 @@ class TopicEmbed < ActiveRecord::Basebelongs_to :topicbelongs_to :post- validates_presence_of :embed_url- validates_uniqueness_of :embed_url+ validates :embed_url, presence: true+ validates :embed_url, uniqueness: truevalidates :embed_content_cache, length: { maximum: EMBED_CONTENT_CACHE_MAX_LENGTH }before_validation(on: :create) dodiff --git a/app/models/topic_invite.rb b/app/models/topic_invite.rbindex 52f63070c7a..c9b6c1295a7 100644--- a/app/models/topic_invite.rb+++ b/app/models/topic_invite.rb@@ -4,10 +4,10 @@ class TopicInvite < ActiveRecord::Basebelongs_to :topicbelongs_to :invite- validates_presence_of :topic_id- validates_presence_of :invite_id+ validates :topic_id, presence: true+ validates :invite_id, presence: true- validates_uniqueness_of :topic_id, scope: :invite_id+ validates :topic_id, uniqueness: { scope: :invite_id }end# == Schema Informationdiff --git a/app/models/topic_link.rb b/app/models/topic_link.rbindex 6b6b6dda8fc..702ce7f5342 100644--- a/app/models/topic_link.rb+++ b/app/models/topic_link.rb@@ -17,11 +17,11 @@ class TopicLink < ActiveRecord::Basebelongs_to :link_topic, class_name: "Topic"belongs_to :link_post, class_name: "Post"- validates_presence_of :url+ validates :url, presence: true- validates_length_of :url, maximum: 500+ validates :url, length: { maximum: 500 }- validates_uniqueness_of :url, scope: %i[topic_id post_id]+ validates :url, uniqueness: { scope: %i[topic_id post_id] }has_many :topic_link_clicks, dependent: :destroydiff --git a/app/models/topic_link_click.rb b/app/models/topic_link_click.rbindex f1236c8c28b..aa3c833fd2f 100644--- a/app/models/topic_link_click.rb+++ b/app/models/topic_link_click.rb@@ -7,7 +7,7 @@ class TopicLinkClick < ActiveRecord::Basebelongs_to :topic_link, counter_cache: :clicksbelongs_to :user- validates_presence_of :topic_link_id+ validates :topic_link_id, presence: trueALLOWED_REDIRECT_HOSTNAMES = Set.new(%W[www.youtube.com youtu.be])diff --git a/app/models/topic_view_item.rb b/app/models/topic_view_item.rbindex 143d22a0056..7801a708c93 100644--- a/app/models/topic_view_item.rb+++ b/app/models/topic_view_item.rb@@ -7,7 +7,7 @@ class TopicViewItem < ActiveRecord::Baseself.table_name = "topic_views"belongs_to :userbelongs_to :topic- validates_presence_of :topic_id, :ip_address, :viewed_at+ validates :topic_id, :ip_address, :viewed_at, presence: truedef self.add(topic_id, ip, user_id = nil, at = nil, skip_redis = false)# Only store a view once per day per thing per (user || ip)diff --git a/app/models/translation_override.rb b/app/models/translation_override.rbindex 5604d6f0f97..69d15530c3e 100644--- a/app/models/translation_override.rb+++ b/app/models/translation_override.rb@@ -45,8 +45,8 @@ class TranslationOverride < ActiveRecord::Baseinclude HasSanitizableFields- validates_uniqueness_of :translation_key, scope: :locale- validates_presence_of :locale, :translation_key, :value+ validates :translation_key, uniqueness: { scope: :locale }+ validates :locale, :translation_key, :value, presence: truevalidate :check_interpolation_keysvalidate :check_MF_string, if: :message_format?diff --git a/app/models/upload.rb b/app/models/upload.rbindex 4cff40ec82c..5f3db6ef5d8 100644--- a/app/models/upload.rb+++ b/app/models/upload.rb@@ -41,9 +41,9 @@ class Upload < ActiveRecord::Baseattr_accessor :validate_file_sizeattr_accessor :skip_video_conversion- validates_presence_of :filesize- validates_presence_of :original_filename- validates :dominant_color, length: { is: 6 }, allow_blank: true, allow_nil: true+ validates :filesize, presence: true+ validates :original_filename, presence: true+ validates :dominant_color, length: { is: 6 }, allow_blank: truevalidates_with UploadValidator@@ -339,11 +339,11 @@ class Upload < ActiveRecord::Base# on demand image size calculation, this allows us to null out image sizes# and still handle as neededdef get_dimension(key)- if v = read_attribute(key)+ if v = self[key]return vendfix_dimensions!- read_attribute(key)+ self[key]enddef widthdiff --git a/app/models/user.rb b/app/models/user.rbindex d2997f3c9ed..c0b65436a5a 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -146,7 +146,7 @@ class User < ActiveRecord::Basedelegate :last_sent_email_address, to: :email_logs- validates_presence_of :username+ validates :username, presence: truevalidate :username_validator, if: :will_save_change_to_username?validate :password_validatorvalidate :name_validator, if: :will_save_change_to_name?@@ -166,6 +166,12 @@ class User < ActiveRecord::Basebefore_validation :set_skip_validate_email+ before_save :update_usernames+ before_save :match_primary_group_changes+ before_save :check_if_title_is_badged_granted+ before_save :apply_watched_words, unless: :should_skip_user_fields_validation?+ before_save :check_qualification_for_users_directory,+ if: Proc.new { SiteSetting.bootstrap_mode_enabled }after_create :create_email_tokenafter_create :create_user_statafter_create :create_user_option@@ -183,13 +189,6 @@ class User < ActiveRecord::Baseafter_update :trigger_user_automatic_group_refresh, if: :saved_change_to_staged?after_update :change_display_name, if: :saved_change_to_name?- before_save :update_usernames- before_save :match_primary_group_changes- before_save :check_if_title_is_badged_granted- before_save :apply_watched_words, unless: :should_skip_user_fields_validation?- before_save :check_qualification_for_users_directory,- if: Proc.new { SiteSetting.bootstrap_mode_enabled }-after_save :expire_tokens_if_password_changedafter_save :clear_global_notice_if_neededafter_save :refresh_avatardiff --git a/app/models/user_action.rb b/app/models/user_action.rbindex b17740e80a2..6387ad767b3 100644--- a/app/models/user_action.rb+++ b/app/models/user_action.rb@@ -7,8 +7,8 @@ class UserAction < ActiveRecord::Basebelongs_to :target_post, class_name: "Post"belongs_to :target_topic, class_name: "Topic"- validates_presence_of :action_type- validates_presence_of :user_id+ validates :action_type, presence: true+ validates :user_id, presence: trueLIKE = 1WAS_LIKED = 2diff --git a/app/models/user_associated_group.rb b/app/models/user_associated_group.rbindex 815309d1aaa..59406ff1108 100644--- a/app/models/user_associated_group.rb+++ b/app/models/user_associated_group.rb@@ -4,8 +4,8 @@ class UserAssociatedGroup < ActiveRecord::Basebelongs_to :userbelongs_to :associated_group- after_commit :add_to_associated_groups, on: %i[create update]before_destroy :remove_from_associated_groups+ after_commit :add_to_associated_groups, on: %i[create update]def add_to_associated_groupsassociated_group.groups.each do |group|diff --git a/app/models/user_field.rb b/app/models/user_field.rbindex fd3bb1ab9c3..1f7c4cad6dd 100644--- a/app/models/user_field.rb+++ b/app/models/user_field.rb@@ -10,8 +10,8 @@ class UserField < ActiveRecord::Basedeprecate_column :required, drop_from: "3.3"self.ignored_columns += %i[field_type]- validates_presence_of :description- validates_presence_of :name, unless: -> { field_type == "confirm" }+ validates :description, presence: true+ validates :name, presence: { unless: -> { field_type == "confirm" } }has_many :user_field_options, dependent: :destroyhas_one :directory_column, dependent: :destroyaccepts_nested_attributes_for :user_field_optionsdiff --git a/app/models/user_history.rb b/app/models/user_history.rbindex 80a510e3de6..16bae1986d9 100644--- a/app/models/user_history.rb+++ b/app/models/user_history.rb@@ -28,7 +28,7 @@ class UserHistory < ActiveRecord::Basevalidates :previous_value, length: { maximum: MAX_JSON_LENGTH }validates :new_value, length: { maximum: MAX_JSON_LENGTH }- validates_presence_of :action+ validates :action, presence: truescope :only_staff_actions, -> { where("action IN (?)", UserHistory.staff_action_ids) }diff --git a/app/models/user_open_id.rb b/app/models/user_open_id.rbindex 3c5b1d457f6..e87fad86b1c 100644--- a/app/models/user_open_id.rb+++ b/app/models/user_open_id.rb@@ -6,8 +6,8 @@ class UserOpenId < ActiveRecord::Basebelongs_to :user- validates_presence_of :email- validates_presence_of :url+ validates :email, presence: true+ validates :url, presence: trueprivatediff --git a/app/models/user_option.rb b/app/models/user_option.rbindex 3c84be668a4..9e1c57f5540 100644--- a/app/models/user_option.rb+++ b/app/models/user_option.rb@@ -23,9 +23,9 @@ class UserOption < ActiveRecord::Baseself.primary_key = :user_idbelongs_to :user+ before_save :update_hide_profile_and_presencebefore_create :set_defaults- before_save :update_hide_profile_and_presenceafter_save :update_tracked_topicsscope :human_users, -> { where("user_id > 0") }diff --git a/app/models/user_profile_view.rb b/app/models/user_profile_view.rbindex 0648b75eb0b..c0406f2f559 100644--- a/app/models/user_profile_view.rb+++ b/app/models/user_profile_view.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueclass UserProfileView < ActiveRecord::Base- validates_presence_of :user_profile_id, :viewed_at+ validates :user_profile_id, :viewed_at, presence: truebelongs_to :user_profilediff --git a/app/models/watched_word.rb b/app/models/watched_word.rbindex f91a4e0ac3f..b7b16c515d3 100644--- a/app/models/watched_word.rb+++ b/app/models/watched_word.rb@@ -28,8 +28,8 @@ class WatchedWord < ActiveRecord::Baseendend- after_save -> { WordWatcher.clear_cache! }after_destroy -> { WordWatcher.clear_cache! }+ after_save -> { WordWatcher.clear_cache! }scope :for,->(word:) dodiff --git a/app/models/web_hook.rb b/app/models/web_hook.rbindex b1492d96f47..d9b9c27181e 100644--- a/app/models/web_hook.rb+++ b/app/models/web_hook.rb@@ -14,9 +14,9 @@ class WebHook < ActiveRecord::Basevalidates :payload_url, presence: true, format: URI.regexp(%w[http https])validates :secret, length: { minimum: 12 }, allow_blank: true- validates_presence_of :content_type- validates_presence_of :last_delivery_status- validates_presence_of :web_hook_event_types, unless: :wildcard_web_hook?+ validates :content_type, presence: true+ validates :last_delivery_status, presence: true+ validates :web_hook_event_types, presence: { unless: :wildcard_web_hook? }validate :ensure_payload_url_allowed, if: :payload_url_changed?before_save :strip_urldiff --git a/app/serializers/post_revision_serializer.rb b/app/serializers/post_revision_serializer.rbindex fa4f92bec0f..7a18518f36f 100644--- a/app/serializers/post_revision_serializer.rb+++ b/app/serializers/post_revision_serializer.rb@@ -257,7 +257,7 @@ class PostRevisionSerializer < ApplicationSerializer# backtrackpost_revisions.each do |pr|- revision = HashWithIndifferentAccess.new+ revision = ActiveSupport::HashWithIndifferentAccess.newrevision[:revision] = pr.numberrevision[:hidden] = pr.hiddendiff --git a/app/services/user_updater.rb b/app/services/user_updater.rbindex 87fc1f7ef05..dcb62f65808 100644--- a/app/services/user_updater.rb+++ b/app/services/user_updater.rb@@ -113,7 +113,7 @@ class UserUpdateruser_notification_schedule.assign_attributes(attributes[:user_notification_schedule])end- old_user_name = user.name.present? ? user.name : ""+ old_user_name = user.name.presence || ""user.name = attributes.fetch(:name) { user.name } if guardian.can_edit_name?(user)diff --git a/config/application.rb b/config/application.rbindex 6724d376ab4..5a3cbfc067d 100644--- a/config/application.rb+++ b/config/application.rb@@ -84,7 +84,7 @@ module Discourseconfig.active_record.belongs_to_required_by_default = falseconfig.active_record.yaml_column_permitted_classes = [Hash,- HashWithIndifferentAccess,+ ActiveSupport::HashWithIndifferentAccess,Time,Symbol,]diff --git a/config/initializers/004-message_bus.rb b/config/initializers/004-message_bus.rbindex 077f27b43bd..0f0c61b4f94 100644--- a/config/initializers/004-message_bus.rb+++ b/config/initializers/004-message_bus.rb@@ -123,7 +123,7 @@ MessageBus.on_disconnect do |site_id|ActiveRecord::Base.connection_handler.clear_active_connections!end-if Rails.env == "test"+if Rails.env.test?MessageBus.configure(backend: :memory)elseMessageBus.redis_config = GlobalSetting.message_bus_redis_config@@ -135,7 +135,7 @@ MessageBus.long_polling_enabled =GlobalSetting.enable_long_polling.nil? ? true : GlobalSetting.enable_long_pollingMessageBus.long_polling_interval = GlobalSetting.long_polling_interval || 25_000-if Rails.env == "test" || $0 =~ /rake$/+if Rails.env.test? || $0 =~ /rake$/# disable keepalive in testingMessageBus.keepalive_interval = -1enddiff --git a/config/initializers/200-first_middlewares.rb b/config/initializers/200-first_middlewares.rbindex 329704e69c0..6d970ac4463 100644--- a/config/initializers/200-first_middlewares.rb+++ b/config/initializers/200-first_middlewares.rb@@ -13,7 +13,7 @@ Rails.configuration.middleware.unshift(MessageBus::Rack::Middleware)# no reason to track this in development, that is 300+ redis calls saved per# page view (we serve all assets out of thin in development)-if Rails.env != "development" || ENV["TRACK_REQUESTS"]+if !Rails.env.development? || ENV["TRACK_REQUESTS"]require "middleware/request_tracker"Rails.configuration.middleware.unshift(Middleware::RequestTracker)Rails.configuration.middleware.move_before(Middleware::RequestTracker, ActionDispatch::RemoteIp)diff --git a/config/initializers/300-perf.rb b/config/initializers/300-perf.rbindex 86822bff8a0..8ce7a012ab5 100644--- a/config/initializers/300-perf.rb+++ b/config/initializers/300-perf.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-if Rails.env == "production"+if Rails.env.production?# This event happens quite a lot and fans out to ExplainSubscriber# and Logger, this cuts out 2 method calls that every time we run SQL#diff --git a/config/routes.rb b/config/routes.rbindex fcf65f8c711..9c5a75e02be 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -27,7 +27,7 @@ Discourse::Application.routes.draw domatch "/404", to: "exceptions#not_found", via: %i[get post]get "/404-body" => "exceptions#not_found_body"- if Rails.env.test? || Rails.env.development?+ if Rails.env.local?get "/bootstrap/plugin-css-for-tests.css" => "bootstrap#plugin_css_for_tests"get "/bootstrap/core-css-for-tests.css" => "bootstrap#core_css_for_tests"enddiff --git a/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb b/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rbindex 28241e035d5..d41bb1093e0 100644--- a/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb+++ b/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb@@ -13,8 +13,7 @@ class FillPersonalMessageEnabledGroupsBasedOnDeprecatedSettings < ActiveRecord::DB.query_single("SELECT value FROM site_settings WHERE name = 'min_trust_to_send_messages'",).first- min_trust_to_send_messages =- (min_trust_to_send_messages_raw.blank? ? 1 : min_trust_to_send_messages_raw).to_i+ min_trust_to_send_messages = (min_trust_to_send_messages_raw.presence || 1).to_i# default to TL1, Group::AUTO_GROUPS[:trust_level_1] is 11personal_message_enabled_groups = "11"diff --git a/db/migrate/20221110175456_populate_default_composer_category.rb b/db/migrate/20221110175456_populate_default_composer_category.rbindex 22692d3ea11..3e1a25c7a76 100644--- a/db/migrate/20221110175456_populate_default_composer_category.rb+++ b/db/migrate/20221110175456_populate_default_composer_category.rb@@ -10,7 +10,7 @@ class PopulateDefaultComposerCategory < ActiveRecord::Migration[7.0]return if general_category_id.blank? || general_category_id[0].to_i < 0default_composer_category =DB.query_single("SELECT value FROM site_settings where name = 'default_composer_category'")- return if !default_composer_category.blank?+ return if default_composer_category.present?DB.exec("INSERT INTO site_settings(name, value, data_type, created_at, updated_at)VALUES('default_composer_category', :setting, '16', NOW(), NOW())",diff --git a/lib/auth/default_current_user_provider.rb b/lib/auth/default_current_user_provider.rbindex 2b37c1252d7..8bfb71f4436 100644--- a/lib/auth/default_current_user_provider.rb+++ b/lib/auth/default_current_user_provider.rb@@ -113,11 +113,11 @@ class Auth::DefaultCurrentUserProvideruser_api_key = @env[USER_API_KEY]api_key = @env[HEADER_API_KEY]- if [email protected]? && request[PARAMETER_USER_API_KEY] && api_parameter_allowed?+ if @env.present? && request[PARAMETER_USER_API_KEY] && api_parameter_allowed?user_api_key ||= request[PARAMETER_USER_API_KEY]end- api_key ||= request[API_KEY] if [email protected]? && request[API_KEY] && api_parameter_allowed?+ api_key ||= request[API_KEY] if @env.present? && request[API_KEY] && api_parameter_allowed?auth_token = find_auth_tokencurrent_user = nildiff --git a/lib/bookmark_manager.rb b/lib/bookmark_manager.rbindex ce3866f374e..5f2c4244741 100644--- a/lib/bookmark_manager.rb+++ b/lib/bookmark_manager.rb@@ -149,11 +149,8 @@ class BookmarkManagermodel_options = { pinned: options[:pinned] }if options[:auto_delete_preference].blank?- model_options[:auto_delete_preference] = if user_auto_delete_preference.present?- user_auto_delete_preference- else+ model_options[:auto_delete_preference] = user_auto_delete_preference.presence ||Bookmark.auto_delete_preferences[:clear_reminder]- endelsemodel_options[:auto_delete_preference] = options[:auto_delete_preference]enddiff --git a/lib/configurable_urls.rb b/lib/configurable_urls.rbindex feb256ab162..cd09575c26f 100644--- a/lib/configurable_urls.rb+++ b/lib/configurable_urls.rb@@ -2,7 +2,7 @@module ConfigurableUrlsdef faq_path- SiteSetting.faq_url.blank? ? "#{Discourse.base_path}/faq" : SiteSetting.faq_url+ SiteSetting.faq_url.presence || "#{Discourse.base_path}/faq"enddef tos_urldiff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rbindex cb9c48f169f..a0f357933ef 100644--- a/lib/cooked_post_processor.rb+++ b/lib/cooked_post_processor.rb@@ -439,7 +439,7 @@ class CookedPostProcessordef process_hotlinked_image(img)onebox = img.ancestors(".onebox, .onebox-body").first- @hotlinked_map ||= @post.post_hotlinked_media.preload(:upload).map { |r| [r.url, r] }.to_h+ @hotlinked_map ||= @post.post_hotlinked_media.preload(:upload).index_by(&:url)normalized_src =PostHotlinkedMedia.normalize_src(img["src"] || img[PrettyText::BLOCKED_HOTLINKED_SRC_ATTR])info = @hotlinked_map[normalized_src]diff --git a/lib/crawler_detection.rb b/lib/crawler_detection.rbindex f926d3455df..6efd1c872d2 100644--- a/lib/crawler_detection.rb+++ b/lib/crawler_detection.rb@@ -6,7 +6,7 @@ module CrawlerDetectiondef self.to_matcher(string, type: nil)escaped = string.split("|").map { |agent| Regexp.escape(agent) }.join("|")- if type == :real && Rails.env == "test"+ if type == :real && Rails.env.test?# we need this bypass so we properly render viewsescaped << "|Rails Testing"enddiff --git a/lib/demon/email_sync.rb b/lib/demon/email_sync.rbindex 9f25c4f06b0..8d07145f3c5 100644--- a/lib/demon/email_sync.rb+++ b/lib/demon/email_sync.rb@@ -178,7 +178,7 @@ class Demon::EmailSync < ::Demon::BaseRailsMultisite::ConnectionManagement.each_connection do |db|next if !SiteSetting.enable_imap- groups = Group.with_imap_configured.map { |group| [group.id, group] }.to_h+ groups = Group.with_imap_configured.index_by(&:id)@sync_lock.synchronize do@sync_data[db] ||= {}diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rbindex af80f8b0631..34708f7780d 100644--- a/lib/discourse_plugin_registry.rb+++ b/lib/discourse_plugin_registry.rb@@ -60,8 +60,8 @@ class DiscoursePluginRegistrydefine_register :desktop_stylesheets, Hashdefine_register :color_definition_stylesheets, Hashdefine_register :serialized_current_user_fields, Set- define_register :seed_data, HashWithIndifferentAccess- define_register :locales, HashWithIndifferentAccess+ define_register :seed_data, ActiveSupport::HashWithIndifferentAccess+ define_register :locales, ActiveSupport::HashWithIndifferentAccessdefine_register :svg_icons, Setdefine_register :custom_html, Hashdefine_register :html_builders, Hashdiff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rbindex a0d7773dc0b..4ba1f6f50e9 100644--- a/lib/discourse_tagging.rb+++ b/lib/discourse_tagging.rb@@ -174,11 +174,7 @@ module DiscourseTagging.map do |tag|tag_name = tag.name- if parent_child_names_map[tag_name].present?- parent_child_names_map[tag_name]- else- tag_name- end+ parent_child_names_map[tag_name].presence || tag_nameend.uniq.sort@@ -600,7 +596,7 @@ module DiscourseTaggingif opts[:order_popularity]builder.order_by("#{topic_count_column} DESC, name")- elsif opts[:order_search_results] && !term.blank?+ elsif opts[:order_search_results] && term.present?builder.order_by("lower(name) = lower(:cleaned_term) DESC, #{topic_count_column} DESC, name")enddiff --git a/lib/email/styles.rb b/lib/email/styles.rbindex 16216604e50..dadd25c7d70 100644--- a/lib/email/styles.rb+++ b/lib/email/styles.rb@@ -45,7 +45,7 @@ module Emailcss = EmailStyle.new.compiled_css@custom_styles = {}- if !css.blank?+ if css.present?# there is a minor race condition here, CssParser could be# loaded by ::CssParser::Parser not loadedrequire "css_parser" unless defined?(::CssParser::Parser)diff --git a/lib/excerpt_parser.rb b/lib/excerpt_parser.rbindex 2cb1a62a4a3..85a1b0da0f6 100644--- a/lib/excerpt_parser.rb+++ b/lib/excerpt_parser.rb@@ -81,9 +81,9 @@ class ExcerptParser < Nokogiri::XML::SAX::Document# If include_images is set, include the image in markdowncharacters("!") if @markdown_images- if !attributes["alt"].blank?+ if attributes["alt"].present?characters("[#{attributes["alt"]}]")- elsif !attributes["title"].blank?+ elsif attributes["title"].present?characters("[#{attributes["title"]}]")elsecharacters("[#{I18n.t "excerpt_image"}]")diff --git a/lib/external_upload_helpers.rb b/lib/external_upload_helpers.rbindex 92a20503b8f..9700df192c8 100644--- a/lib/external_upload_helpers.rb+++ b/lib/external_upload_helpers.rb@@ -295,7 +295,7 @@ module ExternalUploadHelpersif upload.errors.empty?response_serialized = self.class.serialize_upload(upload)external_upload_stub.destroy!- render json: response_serialized, status: 200+ render json: response_serialized, status: :okelserender_json_error(upload.errors.to_hash.values.flatten, status: 422)enddiff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rbindex d16bfbdc89d..2f0fb28571b 100644--- a/lib/file_store/s3_store.rb+++ b/lib/file_store/s3_store.rb@@ -187,11 +187,7 @@ module FileStoreenddef s3_upload_host- if SiteSetting.Upload.s3_cdn_url.present?- SiteSetting.Upload.s3_cdn_url- else- "https:#{absolute_base_url}"- end+ SiteSetting.Upload.s3_cdn_url.presence || "https:#{absolute_base_url}"enddef external?diff --git a/lib/file_store/to_s3_migration.rb b/lib/file_store/to_s3_migration.rbindex 24564630f83..f07e5d3fc82 100644--- a/lib/file_store/to_s3_migration.rb+++ b/lib/file_store/to_s3_migration.rb@@ -161,7 +161,7 @@ module FileStoreendbucket_has_folder_path = true if @s3_bucket.include? "/"- public_directory = Rails.root.join("public").to_s+ public_directory = Rails.public_path.to_ss3 = Aws::S3::Client.new(@s3_client_options)diff --git a/lib/guardian.rb b/lib/guardian.rbindex 12beb9e6eae..11f87e8f9cf 100644--- a/lib/guardian.rb+++ b/lib/guardian.rb@@ -545,7 +545,7 @@ class Guardianreturn false if [email protected]?allowed_repos = GlobalSetting.allowed_theme_repos- if !allowed_repos.blank?+ if allowed_repos.present?urls = allowed_repos.split(",").map(&:strip)return urls.include?(repo)enddiff --git a/lib/hijack.rb b/lib/hijack.rbindex fd92488aa0d..0447fe359ca 100644--- a/lib/hijack.rb+++ b/lib/hijack.rb@@ -37,7 +37,7 @@ module Hijack&scheduled.method(:resolve))rescue WorkQueue::WorkQueueFull- return render plain: "", status: 503+ return render plain: "", status: :service_unavailableend# duplicate headers so other middleware does not mess with itdiff --git a/lib/import_export/importer.rb b/lib/import_export/importer.rbindex 1498831e46e..087832163b2 100644--- a/lib/import_export/importer.rb+++ b/lib/import_export/importer.rb@@ -238,7 +238,7 @@ module ImportExportenddef fix_permissions- categories_by_id = @categories.to_h { |category| [category[:id], category] }+ categories_by_id = @categories.index_by { _1[:id] }@categories.each do |category|if category[:permissions_params].blank?diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rbindex 776460c1198..e176619b957 100644--- a/lib/js_locale_helper.rb+++ b/lib/js_locale_helper.rb@@ -14,7 +14,7 @@ module JsLocaleHelperenddef self.plugin_translations(locale_str)- @plugin_translations ||= HashWithIndifferentAccess.new+ @plugin_translations ||= ActiveSupport::HashWithIndifferentAccess.new@plugin_translations[locale_str] ||= begintranslations = {}@@ -30,7 +30,7 @@ module JsLocaleHelperenddef self.load_translations(locale)- @loaded_translations ||= HashWithIndifferentAccess.new+ @loaded_translations ||= ActiveSupport::HashWithIndifferentAccess.new@loaded_translations[locale] ||= beginlocale_str = locale.to_s@@ -139,7 +139,7 @@ module JsLocaleHelpermessage_formats =I18n.fallbacks[locale]- .each_with_object(HashWithIndifferentAccess.new) do |l, hash|+ .each_with_object(ActiveSupport::HashWithIndifferentAccess.new) do |l, hash|translations = translations_for(l, no_fallback: true)hash[l] = remove_message_formats!(translations, l).merge(TranslationOverridediff --git a/lib/plain_text_to_markdown.rb b/lib/plain_text_to_markdown.rbindex 249b5194526..29697bad213 100644--- a/lib/plain_text_to_markdown.rb+++ b/lib/plain_text_to_markdown.rb@@ -186,7 +186,7 @@ class PlainTextToMarkdownurls = Set.newtext.scan(URL_REGEX) { urls << $& }- hoisted = urls.map { |url| [SecureRandom.hex, url] }.to_h+ hoisted = urls.index_by { |url| SecureRandom.hex }hoisted.each { |h, url| text.gsub!(url, h) }diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rbindex b575244f5da..aefcfe3f7b2 100644--- a/lib/plugin/instance.rb+++ b/lib/plugin/instance.rb@@ -72,7 +72,7 @@ class Plugin::Instanceenddef seed_data- @seed_data ||= HashWithIndifferentAccess.new({})+ @seed_data ||= ActiveSupport::HashWithIndifferentAccess.new({})enddef seed_fu_filter(filter = nil)diff --git a/lib/post_creator.rb b/lib/post_creator.rbindex 2150322ccce..1eec0e12ec9 100644--- a/lib/post_creator.rb+++ b/lib/post_creator.rb@@ -259,7 +259,7 @@ class PostCreatorenddef self.track_post_stats- Rails.env != "test" || @track_post_stats+ !Rails.env.test? || @track_post_statsenddef self.track_post_stats=(val)diff --git a/lib/pretty_text.rb b/lib/pretty_text.rbindex 44cc28e66c2..183cde9ca07 100644--- a/lib/pretty_text.rb+++ b/lib/pretty_text.rb@@ -272,7 +272,7 @@ module PrettyText__performEmojiUnescape(#{title.inspect}, {getURL: __getURL,emojiSet: #{set},- emojiCDNUrl: "#{SiteSetting.external_emoji_url.blank? ? "" : SiteSetting.external_emoji_url}",+ emojiCDNUrl: "#{SiteSetting.external_emoji_url.presence || ""}",customEmoji: #{custom},enableEmojiShortcuts: #{SiteSetting.enable_emoji_shortcuts},inlineEmoji: #{SiteSetting.enable_inline_emoji_translation}diff --git a/lib/reviewable/collection.rb b/lib/reviewable/collection.rbindex f05e898f483..584c3ebbd7d 100644--- a/lib/reviewable/collection.rb+++ b/lib/reviewable/collection.rb@@ -11,6 +11,8 @@ class Reviewable < ActiveRecord::Baseendend+ delegate :present?, :blank?, to: :@content+def initialize(reviewable, guardian, args = nil)args ||= {}@@ -22,14 +24,6 @@ class Reviewable < ActiveRecord::Base@content.any? { |a| a.server_action.to_s == action_id.to_s }end- def blank?- @content.blank?- end-- def present?- !blank?- end-def each@content.each { |i| yield i }enddiff --git a/lib/second_factor/actions/base.rb b/lib/second_factor/actions/base.rbindex 24ad12d8554..7b9455eb1cf 100644--- a/lib/second_factor/actions/base.rb+++ b/lib/second_factor/actions/base.rb@@ -10,7 +10,7 @@ module SecondFactor::Actions@current_user = guardian.user@target_user = target_user@request = request- @opts = HashWithIndifferentAccess.new(opts)+ @opts = ActiveSupport::HashWithIndifferentAccess.new(opts)enddef skip_second_factor_auth?(params)diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rbindex 1c9787f83fa..e09070e1706 100644--- a/lib/site_setting_extension.rb+++ b/lib/site_setting_extension.rb@@ -39,7 +39,7 @@ module SiteSettingExtension# note optimised cause this is called a lot so avoiding .presence which# adds 2 method callslocale = current[:default_locale]- if locale && !locale.blank?+ if locale && locale.present?localeelseSiteSettings::DefaultsProvider::DEFAULT_LOCALEdiff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rakeindex 215bfb52f1c..2d7835eb87f 100644--- a/lib/tasks/docker.rake+++ b/lib/tasks/docker.rake@@ -51,7 +51,7 @@ def setup_test_env(success &&= run_or_fail("bundle exec rake plugin:install_all_official") if install_all_officialsuccess &&= run_or_fail("bundle exec rake plugin:update_all") if update_all_plugins- if !plugins_to_remove.blank?+ if plugins_to_remove.present?plugins_to_remove.split(",").map(&:strip)diff --git a/lib/tasks/rspec.rake b/lib/tasks/rspec.rakeindex 7e0ffa2a3b6..a088d6cfcbb 100644--- a/lib/tasks/rspec.rake+++ b/lib/tasks/rspec.rake@@ -1,6 +1,6 @@# frozen_string_literal: true-if Rails.env.development? || Rails.env.test?+if Rails.env.local?require "rspec/core/rake_task"RSpec::Core::RakeTask.new(:spec)diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rakeindex 04341ca6a06..dd4de562194 100644--- a/lib/tasks/uploads.rake+++ b/lib/tasks/uploads.rake@@ -181,7 +181,7 @@ def clean_up_uploadsexit 1 unless backuper.successend- public_directory = Rails.root.join("public").to_s+ public_directory = Rails.public_path.to_s#### DATABASE vs FILE SYSTEM@@ -404,7 +404,7 @@ task "uploads:analyze", %i[cache_path limit] => :environment do |_, args|cache_path = args[:cache_path]current_db = RailsMultisite::ConnectionManagement.current_db- uploads_path = Rails.root.join("public", "uploads", current_db)+ uploads_path = Rails.public_path.join("uploads", current_db)path =if cache_path@@ -1137,7 +1137,7 @@ def fix_missing_s3tempfile =FileHelper.download(upload.url,- max_file_size: 30.megabyte,+ max_file_size: 30.megabytes,tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}",)downloaded_from = upload.url@@ -1147,7 +1147,7 @@ def fix_missing_s3tempfile =FileHelper.download(upload.origin,- max_file_size: 30.megabyte,+ max_file_size: 30.megabytes,tmp_file_name: "#{SecureRandom.hex}.#{upload.extension}",)downloaded_from = upload.origindiff --git a/lib/topic_creator.rb b/lib/topic_creator.rbindex f9c008071d2..a5bb692c3ae 100644--- a/lib/topic_creator.rb+++ b/lib/topic_creator.rb@@ -82,8 +82,7 @@ class TopicCreatordef create_shared_draft(topic)return if @opts[:shared_draft].blank? || @opts[:shared_draft] == "false"- category_id =- @opts[:category].blank? ? SiteSetting.shared_drafts_category.to_i : @opts[:category]+ category_id = @opts[:category].presence || SiteSetting.shared_drafts_category.to_iSharedDraft.create(topic_id: topic.id, category_id: category_id)enddiff --git a/lib/topic_query.rb b/lib/topic_query.rbindex a62e6f63ad9..ccb1efbc7e1 100644--- a/lib/topic_query.rb+++ b/lib/topic_query.rb@@ -244,7 +244,7 @@ class TopicQueryif DiscoursePluginRegistry.list_suggested_for_providers.any?DiscoursePluginRegistry.list_suggested_for_providers.each do |provider|suggested = provider.call(topic, pm_params, self)- builder.add_results(suggested[:result]) if suggested && !suggested[:result].blank?+ builder.add_results(suggested[:result]) if suggested && suggested[:result].present?endenddiff --git a/lib/user_comm_screener.rb b/lib/user_comm_screener.rbindex c1a451bf27a..fee8c29ff62 100644--- a/lib/user_comm_screener.rb+++ b/lib/user_comm_screener.rb@@ -103,7 +103,7 @@ class UserCommScreenerdef initialize(acting_user: nil, acting_user_id: nil, target_user_ids:)raise ArgumentError if acting_user.blank? && acting_user_id.blank?- @acting_user = acting_user.present? ? acting_user : User.find(acting_user_id)+ @acting_user = acting_user.presence || User.find(acting_user_id)target_user_ids = Array.wrap(target_user_ids) - [@acting_user.id]@target_users = User.where(id: target_user_ids).pluck(:id, :username).to_h@preferences = load_preference_mapdiff --git a/migrations/lib/database/schema/loader.rb b/migrations/lib/database/schema/loader.rbindex 3d1fc22cbcc..54872c23726 100644--- a/migrations/lib/database/schema/loader.rb+++ b/migrations/lib/database/schema/loader.rb@@ -17,7 +17,7 @@ module Migrations::Database::Schemadef load_enumsenums = EnumResolver.new(@schema_config[:enums]).resolve- @enums_by_name = enums.map { |enum| [enum.name, enum] }.to_h+ @enums_by_name = enums.index_by(&:name)enumsenddiff --git a/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb b/plugins/automation/app/jobs/regular/discourse_automation/trigger.rbindex bf19e90312b..09adc6c47d1 100644--- a/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb+++ b/plugins/automation/app/jobs/regular/discourse_automation/trigger.rb@@ -3,7 +3,7 @@module Jobsmodule DiscourseAutomationclass Trigger < ::Jobs::Base- RETRY_TIMES = [5.minute, 15.minute, 120.minute]+ RETRY_TIMES = [5.minutes, 15.minutes, 120.minutes]sidekiq_options retry: RETRY_TIMES.sizediff --git a/plugins/automation/spec/requests/admin_discourse_automation_automations_spec.rb b/plugins/automation/spec/requests/admin_discourse_automation_automations_spec.rbindex ef66d2da095..4aad3e88785 100644--- a/plugins/automation/spec/requests/admin_discourse_automation_automations_spec.rb+++ b/plugins/automation/spec/requests/admin_discourse_automation_automations_spec.rb@@ -257,7 +257,7 @@ describe DiscourseAutomation::AdminAutomationsController doautomation.upsert_field!("execute_at","date_time",- { value: 1.hours.from_now },+ { value: 1.hour.from_now },target: "trigger",)end@@ -265,7 +265,7 @@ describe DiscourseAutomation::AdminAutomationsController doit "updates the associated pending automation execute_at" doexpect(automation.pending_automations.count).to eq(1)expect(automation.pending_automations.last.execute_at).to be_within_one_minute_of(- 1.hours.from_now,+ 1.hour.from_now,)expect {diff --git a/plugins/automation/spec/triggers/recurring_spec.rb b/plugins/automation/spec/triggers/recurring_spec.rbindex 27126fd50d2..ff603163cee 100644--- a/plugins/automation/spec/triggers/recurring_spec.rb+++ b/plugins/automation/spec/triggers/recurring_spec.rb@@ -243,7 +243,7 @@ describe "Recurring" doexpect(automation.pending_automations.count).to eq(1)expect(automation.pending_automations.last.execute_at).to be_within_one_second_of(- Time.zone.now + 2.days,+ 2.days.from_now,)endend@@ -287,7 +287,7 @@ describe "Recurring" doexpect(automation.pending_automations.count).to eq(1)expect(automation.pending_automations.last.execute_at).to be_within_one_second_of(- Time.zone.now + 2.hour,+ 2.hours.from_now,)endend@@ -390,7 +390,7 @@ describe "Recurring" dopending_automation = automation.pending_automations.laststart_date = Time.parse(automation.trigger_field("start_date")["value"])- expect(pending_automation.execute_at).to be_within_one_minute_of(start_date + 3.day)+ expect(pending_automation.execute_at).to be_within_one_minute_of(start_date + 3.days)endit "creates the next iteration three days after without Saturday/Sunday" do@@ -422,7 +422,7 @@ describe "Recurring" dopending_automation = automation.pending_automations.lastexpect(pending_automation.execute_at).to be_within_one_minute_of(- (Time.zone.now + 1.hour).beginning_of_hour,+ 1.hour.from_now.beginning_of_hour,)endend@@ -435,7 +435,7 @@ describe "Recurring" dopending_automation = automation.pending_automations.lastexpect(pending_automation.execute_at).to be_within_one_minute_of(- (Time.zone.now + 1.minute).beginning_of_minute,+ 1.minute.from_now.beginning_of_minute,)endenddiff --git a/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb b/plugins/chat/app/controllers/chat/api/channel_messages_controller.rbindex da3b450c834..1ff8586b39c 100644--- a/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channel_messages_controller.rb@@ -11,12 +11,12 @@ class Chat::Api::ChannelMessagesController < Chat::ApiController**service_params,) do |result|on_success { render_serialized(result, ::Chat::MessagesSerializer, root: false) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess }on_failed_policy(:target_message_exists) { raise Discourse::NotFound }on_model_not_found(:channel) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -24,11 +24,11 @@ class Chat::Api::ChannelMessagesController < Chat::ApiControllerdef destroyChat::TrashMessage.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -36,11 +36,11 @@ class Chat::Api::ChannelMessagesController < Chat::ApiControllerdef bulk_destroyChat::TrashMessages.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:messages) { raise Discourse::NotFound }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -48,11 +48,11 @@ class Chat::Api::ChannelMessagesController < Chat::ApiControllerdef restoreChat::RestoreMessage.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -60,13 +60,13 @@ class Chat::Api::ChannelMessagesController < Chat::ApiControllerdef updateChat::UpdateMessage.call(service_params) doon_success { |message:| render json: success_json.merge(message_id: message.id) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_model_errors(:message) do |model|render_json_error(model.errors.map(&:full_message).join(", "))endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -78,7 +78,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiControlleron_success do |message_instance:|render json: success_json.merge(message_id: message_instance.id)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:no_silenced_user) { raise Discourse::InvalidAccess }on_model_not_found(:channel) { raise Discourse::NotFound }on_failed_policy(:allowed_to_join_channel) { raise Discourse::InvalidAccess }@@ -98,7 +98,7 @@ class Chat::Api::ChannelMessagesController < Chat::ApiControllerrender_json_error(model.errors.map(&:full_message).join(", "))endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb b/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rbindex 74e0dba5415..8c1cd17b179 100644--- a/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channel_thread_messages_controller.rb@@ -19,12 +19,12 @@ class Chat::Api::ChannelThreadMessagesController < Chat::ApiControllerinclude_thread_original_message: false,)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:target_message_exists) { raise Discourse::NotFound }on_failed_policy(:can_view_thread) { raise Discourse::InvalidAccess }on_model_not_found(:thread) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb b/plugins/chat/app/controllers/chat/api/channel_threads_controller.rbindex 9e313851f57..a90fec4c545 100644--- a/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channel_threads_controller.rb@@ -22,9 +22,9 @@ class Chat::Api::ChannelThreadsController < Chat::ApiControlleron_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess }on_model_not_found(:channel) { raise Discourse::NotFound }on_model_not_found(:threads) { render json: success_json.merge(threads: []) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -45,9 +45,9 @@ class Chat::Api::ChannelThreadsController < Chat::ApiControlleron_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound }on_model_not_found(:thread) { raise Discourse::NotFound }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -59,12 +59,12 @@ class Chat::Api::ChannelThreadsController < Chat::ApiControlleron_failed_policy(:can_edit_thread) { raise Discourse::InvalidAccess }on_model_not_found(:thread) { raise Discourse::NotFound }on_failed_step(:update) do |step|- render json: failed_json.merge(errors: [step.error]), status: 422+ render json: failed_json.merge(errors: [step.error]), status: :unprocessable_entityendon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -80,15 +80,16 @@ class Chat::Api::ChannelThreadsController < Chat::ApiController)endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endon_model_not_found(:channel) { raise Discourse::NotFound }on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess }on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound }on_model_errors(:thread) do |model|- render json: failed_json.merge(errors: [model.errors.full_messages.join(", ")]), status: 422+ render json: failed_json.merge(errors: [model.errors.full_messages.join(", ")]),+ status: :unprocessable_entityend- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }endendenddiff --git a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rbindex abce511e4e4..5776d80da5a 100644--- a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_notifications_settings_controller.rb@@ -6,12 +6,12 @@ class Chat::Api::ChannelThreadsCurrentUserNotificationsSettingsController < Chaton_success do |membership:|render_serialized(membership, Chat::BaseThreadMembershipSerializer, root: "membership")end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound }on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess }on_model_not_found(:thread) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rbindex 6a740e9a5b5..4e068a5428a 100644--- a/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channel_threads_current_user_title_prompt_seen_controller.rb@@ -6,12 +6,12 @@ class Chat::Api::ChannelThreadsCurrentUserTitlePromptSeenController < Chat::ApiCon_success do |membership:|render_serialized(membership, Chat::BaseThreadMembershipSerializer, root: "membership")end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:threading_enabled_for_channel) { raise Discourse::NotFound }on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess }on_model_not_found(:thread) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_archives_controller.rb b/plugins/chat/app/controllers/chat/api/channels_archives_controller.rbindex 51ac0be0fdb..aaebe7536f5 100644--- a/plugins/chat/app/controllers/chat/api/channels_archives_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_archives_controller.rb@@ -26,7 +26,7 @@ class Chat::Api::ChannelsArchivesController < Chat::Api::ChannelsControllertopic_params: topic_params,)rescue Chat::ChannelArchiveService::ArchiveValidationError => err- return render json: failed_json.merge(errors: err.errors), status: 400+ return render json: failed_json.merge(errors: err.errors), status: :bad_requestendrender json: success_jsondiff --git a/plugins/chat/app/controllers/chat/api/channels_controller.rb b/plugins/chat/app/controllers/chat/api/channels_controller.rbindex df88bb3b51b..0c47fa72d87 100644--- a/plugins/chat/app/controllers/chat/api/channels_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_controller.rb@@ -33,9 +33,9 @@ class Chat::Api::ChannelsController < Chat::ApiControlleron_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_model_not_found(:channel) { raise ActiveRecord::RecordNotFound }on_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -71,9 +71,9 @@ class Chat::Api::ChannelsController < Chat::ApiControlleron_model_errors(:membership) do |model|render_json_error(model, type: :record_invalid, status: 422)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rbindex b7bf7e51249..5f80112a537 100644--- a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_controller.rb@@ -14,10 +14,10 @@ class Chat::Api::ChannelsCurrentUserMembershipController < Chat::Api::ChannelsCodef destroyChat::LeaveChannel.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:channel) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rbindex bc17163fd73..2eb273dac51 100644--- a/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_current_user_membership_follows_controller.rb@@ -7,10 +7,10 @@ class Chat::Api::ChannelsCurrentUserMembershipFollowsController < Chat::Api::Charender_serialized(membership, Chat::UserChannelMembershipSerializer, root: "membership")endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endon_model_not_found(:channel) { raise Discourse::NotFound }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb b/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rbindex b221aa74744..ae62470d086 100644--- a/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_drafts_controller.rb@@ -4,10 +4,10 @@ class Chat::Api::ChannelsDraftsController < Chat::ApiControllerdef createChat::UpsertDraft.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:channel) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb b/plugins/chat/app/controllers/chat/api/channels_invites_controller.rbindex ca992049184..9c295d1727b 100644--- a/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_invites_controller.rb@@ -4,11 +4,11 @@ class Chat::Api::ChannelsInvitesController < Chat::ApiControllerdef createChat::InviteUsersToChannel.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:can_view_channel) { raise Discourse::InvalidAccess }on_model_not_found(:channel) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb b/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rbindex e33a0cc42b4..fa9d90c5285 100644--- a/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_memberships_controller.rb@@ -32,7 +32,7 @@ class Chat::Api::ChannelsMembershipsController < Chat::Api::ChannelsControllerdef createChat::AddUsersToChannel.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:can_add_users_to_channel) dorender_json_error(I18n.t("chat.errors.users_cant_be_added_to_channel"))end@@ -40,7 +40,7 @@ class Chat::Api::ChannelsMembershipsController < Chat::Api::ChannelsControllerrender_json_dump({ error: policy.reason }, status: 400)endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -48,14 +48,14 @@ class Chat::Api::ChannelsMembershipsController < Chat::Api::ChannelsControllerdef destroyChat::RemoveUserFromChannel.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:channel) { raise Discourse::NotFound }on_model_not_found(:target_user) { raise Discourse::NotFound }on_failed_policy(:can_remove_users_from_channel) dorender_json_error(I18n.t("chat.errors.user_cant_be_removed_from_channel"), status: 403)endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb b/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rbindex a3fd12eba5e..5b6b2280224 100644--- a/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_messages_flags_controller.rb@@ -2,15 +2,15 @@class Chat::Api::ChannelsMessagesFlagsController < Chat::ApiControllerdef create- RateLimiter.new(current_user, "flag_chat_message", 4, 1.minutes).performed!+ RateLimiter.new(current_user, "flag_chat_message", 4, 1.minute).performed!Chat::FlagMessage.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_policy(:can_flag_message_in_channel) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_messages_interactions_controller.rb b/plugins/chat/app/controllers/chat/api/channels_messages_interactions_controller.rbindex af802b8d49d..db6123c1c98 100644--- a/plugins/chat/app/controllers/chat/api/channels_messages_interactions_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_messages_interactions_controller.rb@@ -6,11 +6,11 @@ class Chat::Api::ChannelsMessagesInteractionsController < Chat::ApiControlleron_success do |interaction:|render_serialized(interaction, Chat::MessageInteractionSerializer, root: "interaction")end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_model_not_found(:action) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb b/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rbindex 5094f9dd39d..9f591fb85fa 100644--- a/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_messages_streaming_controller.rb@@ -4,12 +4,12 @@ class Chat::Api::ChannelsMessagesStreamingController < Chat::Api::ChannelsControdef destroyChat::StopMessageStreaming.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:message) { raise Discourse::NotFound }on_model_not_found(:membership) { raise Discourse::NotFound }on_failed_policy(:can_stop_streaming) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_read_controller.rb b/plugins/chat/app/controllers/chat/api/channels_read_controller.rbindex a02a21a77dc..8af7b040290 100644--- a/plugins/chat/app/controllers/chat/api/channels_read_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_read_controller.rb@@ -4,7 +4,7 @@ class Chat::Api::ChannelsReadController < Chat::ApiControllerdef updateChat::UpdateUserChannelLastRead.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_policy(:ensure_message_id_recency) doraise Discourse::InvalidParameters.new(:message_id)end@@ -13,7 +13,7 @@ class Chat::Api::ChannelsReadController < Chat::ApiControlleron_model_not_found(:channel) { raise Discourse::NotFound }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendend@@ -21,7 +21,7 @@ class Chat::Api::ChannelsReadController < Chat::ApiControllerdef update_allChat::MarkAllUserChannelsRead.call(service_params) doon_success { |updated_memberships:| render(json: success_json.merge(updated_memberships:)) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_status_controller.rb b/plugins/chat/app/controllers/chat/api/channels_status_controller.rbindex cd97271c6d0..ec4c8cc0240 100644--- a/plugins/chat/app/controllers/chat/api/channels_status_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_status_controller.rb@@ -6,9 +6,9 @@ class Chat::Api::ChannelsStatusController < Chat::Api::ChannelsControlleron_success { |channel:| render_serialized(channel, Chat::ChannelSerializer, root: "channel") }on_model_not_found(:channel) { raise ActiveRecord::RecordNotFound }on_failed_policy(:check_channel_permission) { raise Discourse::InvalidAccess }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb b/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rbindex 292fbbbfd22..b017e1cbe35 100644--- a/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_threads_drafts_controller.rb@@ -4,11 +4,11 @@ class Chat::Api::ChannelsThreadsDraftsController < Chat::ApiControllerdef createChat::UpsertDraft.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:channel) { raise Discourse::NotFound }on_failed_step(:check_thread_exists) { raise Discourse::NotFound }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb b/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rbindex cc147436003..eab649228a1 100644--- a/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb+++ b/plugins/chat/app/controllers/chat/api/channels_threads_read_controller.rb@@ -4,12 +4,12 @@ class Chat::Api::ChannelsThreadsReadController < Chat::ApiControllerdef updateChat::UpdateUserThreadLastRead.call(service_params) doon_success { render(json: success_json) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_model_not_found(:thread) { raise Discourse::NotFound }on_model_not_found(:message) { raise Discourse::NotFound }on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/chatables_controller.rb b/plugins/chat/app/controllers/chat/api/chatables_controller.rbindex 166f6b660b9..17f133cfa4c 100644--- a/plugins/chat/app/controllers/chat/api/chatables_controller.rb+++ b/plugins/chat/app/controllers/chat/api/chatables_controller.rb@@ -6,9 +6,9 @@ class Chat::Api::ChatablesController < Chat::ApiControllerdef index::Chat::SearchChatable.call(service_params) do |result|on_success { render_serialized(result, ::Chat::ChatablesSerializer, root: false) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb b/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rbindex d87955a5c24..a1e0853bfa0 100644--- a/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb+++ b/plugins/chat/app/controllers/chat/api/current_user_channels_controller.rb@@ -11,7 +11,7 @@ class Chat::Api::CurrentUserChannelsController < Chat::ApiControllerpost_allowed_category_ids: post_allowed_category_ids,)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }endendenddiff --git a/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb b/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rbindex 5fdaf983455..d7bcde2493d 100644--- a/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb+++ b/plugins/chat/app/controllers/chat/api/current_user_threads_controller.rb@@ -19,10 +19,10 @@ class Chat::Api::CurrentUserThreadsController < Chat::ApiController)endon_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endon_model_not_found(:threads) { render json: success_json.merge(threads: []) }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }endendenddiff --git a/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb b/plugins/chat/app/controllers/chat/api/direct_messages_controller.rbindex 66b756f1be8..dfd4f412ab3 100644--- a/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb+++ b/plugins/chat/app/controllers/chat/api/direct_messages_controller.rb@@ -21,9 +21,9 @@ class Chat::Api::DirectMessagesController < Chat::ApiControlleron_model_errors(:channel) do |model|render_json_error(model, type: :record_invalid, status: 422)end- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|- render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)+ render(json: failed_json.merge(errors: contract.errors.full_messages), status: :bad_request)endendenddiff --git a/plugins/chat/app/controllers/chat/direct_messages_controller.rb b/plugins/chat/app/controllers/chat/direct_messages_controller.rbindex f20c647cfc5..2ab75d8b95b 100644--- a/plugins/chat/app/controllers/chat/direct_messages_controller.rb+++ b/plugins/chat/app/controllers/chat/direct_messages_controller.rb@@ -16,7 +16,7 @@ module Chatmembership: chat_channel.membership_for(current_user),)else- render body: nil, status: 404+ render body: nil, status: :not_foundendenddiff --git a/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb b/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rbindex 105525ad6af..0f807e1a346 100644--- a/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb+++ b/plugins/chat/app/controllers/chat/incoming_webhooks_controller.rb@@ -64,7 +64,7 @@ module Chatincoming_chat_webhook: webhook,) doon_success { render json: success_json }- on_failure { render(json: failed_json, status: 422) }+ on_failure { render(json: failed_json, status: :unprocessable_entity) }on_failed_contract do |contract|raise Discourse::InvalidParameters.new(contract.errors.full_messages)enddiff --git a/plugins/chat/lib/chat/statistics.rb b/plugins/chat/lib/chat/statistics.rbindex c5a57ffa966..793fd57ed9e 100644--- a/plugins/chat/lib/chat/statistics.rb+++ b/plugins/chat/lib/chat/statistics.rb@@ -4,7 +4,7 @@ module Chatclass Statisticsdef self.about_messages{- last_day: Chat::Message.where("created_at > ?", 1.days.ago).count,+ last_day: Chat::Message.where("created_at > ?", 1.day.ago).count,"7_days": Chat::Message.where("created_at > ?", 7.days.ago).count,"30_days": Chat::Message.where("created_at > ?", 30.days.ago).count,previous_30_days:@@ -15,7 +15,7 @@ module Chatdef self.about_channels{- last_day: Chat::Channel.where(status: :open).where("created_at > ?", 1.days.ago).count,+ last_day: Chat::Channel.where(status: :open).where("created_at > ?", 1.day.ago).count,"7_days": Chat::Channel.where(status: :open).where("created_at > ?", 7.days.ago).count,"30_days": Chat::Channel.where(status: :open).where("created_at > ?", 30.days.ago).count,previous_30_days:@@ -29,7 +29,7 @@ module Chatdef self.about_users{- last_day: Chat::Message.where("created_at > ?", 1.days.ago).distinct.count(:user_id),+ last_day: Chat::Message.where("created_at > ?", 1.day.ago).distinct.count(:user_id),"7_days": Chat::Message.where("created_at > ?", 7.days.ago).distinct.count(:user_id),"30_days": Chat::Message.where("created_at > ?", 30.days.ago).distinct.count(:user_id),previous_30_days:@@ -46,7 +46,7 @@ module ChatChat::Message.joins(:chat_channel).where.not(chat_channel: { type: "DirectMessageChannel" }){- last_day: query.where("chat_messages.created_at > ?", 1.days.ago).count,+ last_day: query.where("chat_messages.created_at > ?", 1.day.ago).count,"7_days": query.where("chat_messages.created_at > ?", 7.days.ago).count,"28_days": query.where("chat_messages.created_at > ?", 28.days.ago).count,"30_days": query.where("chat_messages.created_at > ?", 30.days.ago).count,@@ -59,7 +59,7 @@ module ChatChat::Message.joins(:chat_channel).where(chat_channel: { type: "DirectMessageChannel" }){- last_day: query.where("chat_messages.created_at > ?", 1.days.ago).count,+ last_day: query.where("chat_messages.created_at > ?", 1.day.ago).count,"7_days": query.where("chat_messages.created_at > ?", 7.days.ago).count,"28_days": query.where("chat_messages.created_at > ?", 28.days.ago).count,"30_days": query.where("chat_messages.created_at > ?", 30.days.ago).count,@@ -77,7 +77,7 @@ module Chatquery = Chat::Message.where.not(thread: nil){- last_day: query.where("chat_messages.created_at > ?", 1.days.ago).count,+ last_day: query.where("chat_messages.created_at > ?", 1.day.ago).count,"7_days": query.where("chat_messages.created_at > ?", 7.days.ago).count,"28_days": query.where("chat_messages.created_at > ?", 28.days.ago).count,"30_days": query.where("chat_messages.created_at > ?", 30.days.ago).count,diff --git a/plugins/chat/lib/chat/transcript_service.rb b/plugins/chat/lib/chat/transcript_service.rbindex faaed8552df..fddc6388ad7 100644--- a/plugins/chat/lib/chat/transcript_service.rb+++ b/plugins/chat/lib/chat/transcript_service.rb@@ -142,8 +142,7 @@ module Chatdef thread_title_attr(message, thread)range = thread_ranges[message.id] if thread_ranges.has_key?(message.id)- thread_title =- thread.title.present? ? thread.title : I18n.t("chat.transcript.default_thread_title")+ thread_title = thread.title.presence || I18n.t("chat.transcript.default_thread_title")thread_title += " (#{range})" if range.present?"threadTitle=\"#{thread_title}\""enddiff --git a/plugins/chat/plugin.rb b/plugins/chat/plugin.rbindex 4f26c38d864..8697f666b23 100644--- a/plugins/chat/plugin.rb+++ b/plugins/chat/plugin.rb@@ -216,7 +216,7 @@ after_initialize doadd_to_serializer(:user_option,:chat_sound,- include_condition: -> { !object.chat_sound.blank? },+ include_condition: -> { object.chat_sound.present? },) { object.chat_sound }add_to_serializer(:user_option, :only_chat_push_notifications) do@@ -516,6 +516,4 @@ after_initialize doendend-if Rails.env == "test"- Dir[Rails.root.join("plugins/chat/spec/support/**/*.rb")].each { |f| require f }-end+Dir[Rails.root.join("plugins/chat/spec/support/**/*.rb")].each { |f| require f } if Rails.env.test?diff --git a/plugins/chat/spec/jobs/scheduled/auto_join_users_spec.rb b/plugins/chat/spec/jobs/scheduled/auto_join_users_spec.rbindex cf50674b861..cba48ff6524 100644--- a/plugins/chat/spec/jobs/scheduled/auto_join_users_spec.rb+++ b/plugins/chat/spec/jobs/scheduled/auto_join_users_spec.rb@@ -13,7 +13,7 @@ describe Jobs::Chat::AutoJoinUsers doendfab!(:staged_user) { Fabricate(:user, staged: true) }fab!(:suspended_user) { Fabricate(:user, suspended_till: 1.day.from_now) }- fab!(:silenced_user) { Fabricate(:user, silenced_till: 2.day.from_now) }+ fab!(:silenced_user) { Fabricate(:user, silenced_till: 2.days.from_now) }fab!(:inactive_user) { Fabricate(:user, active: false) }fab!(:anonymous_user) do# When using the `anonymous` fabricator, the `::Chat::AutoJoinChannels` is called in thediff --git a/plugins/chat/spec/lib/chat/transcript_service_spec.rb b/plugins/chat/spec/lib/chat/transcript_service_spec.rbindex 6a5668d641b..8293db1411b 100644--- a/plugins/chat/spec/lib/chat/transcript_service_spec.rb+++ b/plugins/chat/spec/lib/chat/transcript_service_spec.rb@@ -56,7 +56,7 @@ describe Chat::TranscriptService domessage1 =Fabricate(:chat_message,- created_at: 10.minute.ago,+ created_at: 10.minutes.ago,user: user1,chat_channel: channel,message: "an extremely insightful response :)",@@ -72,7 +72,7 @@ describe Chat::TranscriptService domessage3 =Fabricate(:chat_message,- created_at: 1.minutes.ago,+ created_at: 1.minute.ago,user: user1,chat_channel: channel,message: "yay!",diff --git a/plugins/chat/spec/requests/chat/api/channels_controller_spec.rb b/plugins/chat/spec/requests/chat/api/channels_controller_spec.rbindex 4358170d99f..15bbe9511ea 100644--- a/plugins/chat/spec/requests/chat/api/channels_controller_spec.rb+++ b/plugins/chat/spec/requests/chat/api/channels_controller_spec.rb@@ -322,7 +322,7 @@ RSpec.describe Chat::Api::ChannelsController dodescribe "triggers the auto-join process" dofab!(:chatters_group, :group)- fab!(:user) { Fabricate(:user, last_seen_at: 15.minute.ago) }+ fab!(:user) { Fabricate(:user, last_seen_at: 15.minutes.ago) }before doJobs.run_immediately!@@ -555,7 +555,7 @@ RSpec.describe Chat::Api::ChannelsController dodescribe "triggers the auto-join process" dofab!(:chatters_group, :group)- fab!(:another_user) { Fabricate(:user, last_seen_at: 15.minute.ago) }+ fab!(:another_user) { Fabricate(:user, last_seen_at: 15.minutes.ago) }before doJobs.run_immediately!diff --git a/plugins/chat/spec/requests/core_ext/bookmarks_controller_spec.rb b/plugins/chat/spec/requests/core_ext/bookmarks_controller_spec.rbindex c5db4a072d5..ed8cc69a9a1 100644--- a/plugins/chat/spec/requests/core_ext/bookmarks_controller_spec.rb+++ b/plugins/chat/spec/requests/core_ext/bookmarks_controller_spec.rb@@ -21,7 +21,7 @@ RSpec.describe BookmarksController doparams: {bookmarkable_id: bookmark_message.id,bookmarkable_type: "Chat::Message",- reminder_at: (Time.zone.now + 1.day).iso8601,+ reminder_at: 1.day.from_now.iso8601,}expect(response.status).to eq(200)diff --git a/plugins/chat/spec/services/chat/list_channel_messages_spec.rb b/plugins/chat/spec/services/chat/list_channel_messages_spec.rbindex 61951ad5915..f2a9267954d 100644--- a/plugins/chat/spec/services/chat/list_channel_messages_spec.rb+++ b/plugins/chat/spec/services/chat/list_channel_messages_spec.rb@@ -143,7 +143,7 @@ RSpec.describe Chat::ListChannelMessages doFabricate(:chat_message, chat_channel: channel, created_at: 3.days.ago)endfab!(:future_message) do- Fabricate(:chat_message, chat_channel: channel, created_at: 1.days.ago)+ Fabricate(:chat_message, chat_channel: channel, created_at: 1.day.ago)endlet(:optional_params) { { target_date: 2.days.ago } }diff --git a/plugins/chat/spec/services/chat/list_channel_thread_messages_spec.rb b/plugins/chat/spec/services/chat/list_channel_thread_messages_spec.rbindex 80c98db9674..aecbc6a2928 100644--- a/plugins/chat/spec/services/chat/list_channel_thread_messages_spec.rb+++ b/plugins/chat/spec/services/chat/list_channel_thread_messages_spec.rb@@ -144,7 +144,7 @@ RSpec.describe Chat::ListChannelThreadMessages doFabricate(:chat_message,chat_channel: thread.channel,- created_at: 1.days.from_now,+ created_at: 1.day.from_now,thread:,)enddiff --git a/plugins/chat/spec/services/chat/thread/policy/message_existence_spec.rb b/plugins/chat/spec/services/chat/thread/policy/message_existence_spec.rbindex c56b7e43995..6de29751b65 100644--- a/plugins/chat/spec/services/chat/thread/policy/message_existence_spec.rb+++ b/plugins/chat/spec/services/chat/thread/policy/message_existence_spec.rb@@ -4,7 +4,7 @@ RSpec.describe Chat::Thread::Policy::MessageExistence dosubject(:policy) { described_class.new(context) }fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }- fab!(:thread) { Fabricate(:chat_thread) }+ fab!(:thread, :chat_thread)let(:guardian) { user.guardian }let(:context) { Service::Base::Context.build(thread:, guardian:, target_message_id:) }diff --git a/plugins/chat/spec/system/admin/csv_exports_spec.rb b/plugins/chat/spec/system/admin/csv_exports_spec.rbindex 64784243546..5eec7d9bf00 100644--- a/plugins/chat/spec/system/admin/csv_exports_spec.rb+++ b/plugins/chat/spec/system/admin/csv_exports_spec.rb@@ -18,7 +18,7 @@ RSpec.describe "Admin Chat CSV exports", type: :system doJobs.run_immediately!message_1 = Fabricate(:chat_message, created_at: 12.months.ago)message_2 = Fabricate(:chat_message, created_at: 6.months.ago)- message_3 = Fabricate(:chat_message, created_at: 1.months.ago)+ message_3 = Fabricate(:chat_message, created_at: 1.month.ago)message_4 = Fabricate(:chat_message, created_at: Time.now)visit "/admin/plugins/chat"diff --git a/plugins/chat/spec/system/list_channels/drawer_spec.rb b/plugins/chat/spec/system/list_channels/drawer_spec.rbindex c2ffc27854c..3fa1ef3f7c7 100644--- a/plugins/chat/spec/system/list_channels/drawer_spec.rb+++ b/plugins/chat/spec/system/list_channels/drawer_spec.rb@@ -143,7 +143,7 @@ RSpec.describe "List channels | Drawer", type: :system dochat_channel: dm_channel_4,user: user_3,use_service: true,- created_at: 1.days.ago,+ created_at: 1.day.ago,)dm_channel_4.membership_for(current_user).mark_read!diff --git a/plugins/chat/spec/system/message_user_info_spec.rb b/plugins/chat/spec/system/message_user_info_spec.rbindex 44345d4c5d4..76c48503b9a 100644--- a/plugins/chat/spec/system/message_user_info_spec.rb+++ b/plugins/chat/spec/system/message_user_info_spec.rb@@ -74,7 +74,7 @@ RSpec.describe "Message user info", type: :system docontext "with large time difference between messages" dofab!(:message_1) do- Fabricate(:chat_message, chat_channel: channel_1, user: current_user, created_at: 1.days.ago)+ Fabricate(:chat_message, chat_channel: channel_1, user: current_user, created_at: 1.day.ago)endfab!(:message_2) { Fabricate(:chat_message, chat_channel: channel_1, user: current_user) }diff --git a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rbindex a1b5cb48317..a2d48eaf849 100644--- a/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb+++ b/plugins/discourse-adplugin/app/models/ad_plugin/house_ad.rb@@ -146,7 +146,7 @@ module AdPluginenddef self.publish_if_ads_enabled- if AdPlugin::HouseAdSetting.all.any? { |_, adsToShow| !adsToShow.blank? }+ if AdPlugin::HouseAdSetting.all.any? { |_, adsToShow| adsToShow.present? }AdPlugin::HouseAdSetting.publish_settingsendenddiff --git a/plugins/discourse-adplugin/spec/requests/site_controller_spec.rb b/plugins/discourse-adplugin/spec/requests/site_controller_spec.rbindex fb5b36a372d..0cca09beac2 100644--- a/plugins/discourse-adplugin/spec/requests/site_controller_spec.rb+++ b/plugins/discourse-adplugin/spec/requests/site_controller_spec.rb@@ -4,7 +4,7 @@ RSpec.describe SiteController dofab!(:group)fab!(:private_category) { Fabricate(:private_category, group: group) }fab!(:user)- fab!(:group_2) { Fabricate(:group) }+ fab!(:group_2, :group)fab!(:user_with_group) { Fabricate(:user, group_ids: [group.id]) }let!(:anon_ad) dodiff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rbindex 9c15b0d9164..725d2fd5cb6 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/ai_llm_quotas_controller.rb@@ -40,7 +40,7 @@ module DiscourseAihead :no_contentrescue ActiveRecord::RecordNotFound- render json: { error: I18n.t("not_found") }, status: 404+ render json: { error: I18n.t("not_found") }, status: :not_foundendprivatediff --git a/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rbindex 014a3ee4aef..cf5b744ba3b 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/admin/rag_document_fragments_controller.rb@@ -39,7 +39,8 @@ module DiscourseAiif upload.persisted?render json: UploadSerializer.new(upload)else- render json: failed_json.merge(errors: upload.errors.full_messages), status: 422+ render json: failed_json.merge(errors: upload.errors.full_messages),+ status: :unprocessable_entityendendenddiff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rbindex c3a8e137487..844bf118235 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_bot/bot_controller.rb@@ -11,7 +11,7 @@ module DiscourseAiraise Discourse::NotFound if !log.topicguardian.ensure_can_debug_ai_bot_conversation!(log.topic)- render json: AiApiAuditLogSerializer.new(log, root: false), status: 200+ render json: AiApiAuditLogSerializer.new(log, root: false), status: :okenddef show_debug_info@@ -26,7 +26,7 @@ module DiscourseAidebug_info = AiApiAuditLog.where(post: posts).order(created_at: :desc).first- render json: AiApiAuditLogSerializer.new(debug_info, root: false), status: 200+ render json: AiApiAuditLogSerializer.new(debug_info, root: false), status: :okenddef stop_streaming_response@@ -35,14 +35,14 @@ module DiscourseAiDiscourse.redis.del("gpt_cancel:#{post.id}")- render json: {}, status: 200+ render json: {}, status: :okenddef show_bot_usernamebot_user = DiscourseAi::AiBot::EntryPoint.find_user_from_model(params[:username])raise Discourse::InvalidParameters.new(:username) if !bot_user- render json: { bot_username: bot_user.username_lower }, status: 200+ render json: { bot_username: bot_user.username_lower }, status: :okendendenddiff --git a/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rbindex 92117f81488..d8d5d18015b 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/ai_helper/assistant_controller.rb@@ -44,7 +44,7 @@ module DiscourseAiforce_default_locale: force_default_locale,custom_prompt: params[:custom_prompt],),- status: 200+ status: :okendrescue DiscourseAi::Completions::Endpoints::Base::CompletionFailedrender_json_error I18n.t("discourse_ai.ai_helper.errors.completion_request_failed"),@@ -67,7 +67,7 @@ module DiscourseAiinput,current_user,),- status: 200+ status: :okendrescue DiscourseAi::Completions::Endpoints::Base::CompletionFailedrender_json_error I18n.t("discourse_ai.ai_helper.errors.completion_request_failed"),@@ -85,7 +85,7 @@ module DiscourseAiendrender json: DiscourseAi::AiHelper::SemanticCategorizer.new(current_user, opts).categories,- status: 200+ status: :okenddef suggest_tags@@ -99,14 +99,14 @@ module DiscourseAiendrender json: DiscourseAi::AiHelper::SemanticCategorizer.new(current_user, opts).tags,- status: 200+ status: :okenddef suggest_thumbnails(input)hijack dothumbnails = DiscourseAi::AiHelper::Painter.new.commission_thumbnails(input, current_user)- render json: { thumbnails: thumbnails }, status: 200+ render json: { thumbnails: thumbnails }, status: :okendend@@ -161,7 +161,7 @@ module DiscourseAi)end- render json: { success: true, progress_channel: }, status: 200+ render json: { success: true, progress_channel: }, status: :okrescue DiscourseAi::Completions::Endpoints::Base::CompletionFailedrender_json_error I18n.t("discourse_ai.ai_helper.errors.completion_request_failed"),status: 502@@ -193,7 +193,7 @@ module DiscourseAicaption:"#{caption} (#{I18n.t("discourse_ai.ai_helper.image_caption.attribution")})",},- status: 200+ status: :okendrescue DiscourseAi::Completions::Endpoints::Base::CompletionFailed, Net::HTTPBadResponserender_json_error I18n.t("discourse_ai.ai_helper.errors.completion_request_failed"),diff --git a/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rbindex cb5cd242938..6ac186c4cbd 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/discover/discoveries_controller.rb@@ -25,7 +25,7 @@ module DiscourseAiJobs.enqueue(:stream_discover_reply, user_id: current_user.id, query: query)- render json: {}, status: 200+ render json: {}, status: :okenddef continue_convo@@ -59,7 +59,7 @@ module DiscourseAirender json: success_json.merge(topic_id: post.topic_id)rescue StandardError => e- render json: failed_json.merge(errors: [e.message]), status: 422+ render json: failed_json.merge(errors: [e.message]), status: :unprocessable_entityendendenddiff --git a/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rbindex d3f7cfd25cc..f8fb469cb34 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/embeddings/embeddings_controller.rb@@ -39,14 +39,14 @@ module DiscourseAicurrent_user,"semantic-search",MAX_HYDE_SEARCHES_PER_MINUTE,- 1.minutes,+ 1.minute,).performed!elseRateLimiter.new(current_user,"semantic-search-non-hyde",MAX_SEARCHES_PER_MINUTE,- 1.minutes,+ 1.minute,).performed!end@@ -88,7 +88,7 @@ module DiscourseAisemantic_search = DiscourseAi::Embeddings::SemanticSearch.new(guardian)if !semantic_search.cached_query?(query)- RateLimiter.new(current_user, "semantic-search", 60, 1.minutes).performed!+ RateLimiter.new(current_user, "semantic-search", 60, 1.minute).performed!endhijack dodiff --git a/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb b/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rbindex 3a1f8a96d5f..8ab836782fa 100644--- a/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb+++ b/plugins/discourse-ai/app/controllers/discourse_ai/translation/translation_controller.rb@@ -23,7 +23,7 @@ module DiscourseAireturn(render json:failed_json.merge(error: I18n.t("discourse_ai.translation.errors.disabled")),- status: 400+ status: :bad_request)enddiff --git a/plugins/discourse-ai/app/models/ai_persona.rb b/plugins/discourse-ai/app/models/ai_persona.rbindex f626d4d628a..db4c8b40c5c 100644--- a/plugins/discourse-ai/app/models/ai_persona.rb+++ b/plugins/discourse-ai/app/models/ai_persona.rb@@ -37,8 +37,8 @@ class AiPersona < ActiveRecord::Basehas_many :upload_references, as: :target, dependent: :destroyhas_many :uploads, through: :upload_references- before_destroy :ensure_not_systembefore_update :regenerate_rag_fragments+ before_destroy :ensure_not_systemdef self.persona_cache@persona_cache ||= DiscourseAi::MultisiteHash.new("persona_cache")diff --git a/plugins/discourse-ai/app/models/embedding_definition.rb b/plugins/discourse-ai/app/models/embedding_definition.rbindex f2118e8766c..854846b3b85 100644--- a/plugins/discourse-ai/app/models/embedding_definition.rb+++ b/plugins/discourse-ai/app/models/embedding_definition.rb@@ -127,7 +127,7 @@ class EmbeddingDefinition < ActiveRecord::Basevalidates :provider, presence: true, inclusion: provider_namesvalidates :display_name, presence: true, length: { maximum: 100 }validates :tokenizer_class, presence: true, inclusion: tokenizer_names- validates_presence_of :url, :api_key, :dimensions, :max_sequence_length, :pg_function+ validates :url, :api_key, :dimensions, :max_sequence_length, :pg_function, presence: trueafter_create :create_indexesdiff --git a/plugins/discourse-ai/app/models/llm_model.rb b/plugins/discourse-ai/app/models/llm_model.rbindex 3be95d82dd1..abd45767d45 100644--- a/plugins/discourse-ai/app/models/llm_model.rb+++ b/plugins/discourse-ai/app/models/llm_model.rb@@ -11,7 +11,7 @@ class LlmModel < ActiveRecord::Basevalidates :tokenizer, presence: true, inclusion: DiscourseAi::Completions::Llm.tokenizer_namesvalidates :provider, presence: true, inclusion: DiscourseAi::Completions::Llm.provider_namesvalidates :url, presence: true, unless: -> { provider == BEDROCK_PROVIDER_NAME }- validates_presence_of :name, :api_key+ validates :name, :api_key, presence: truevalidates :max_prompt_tokens, numericality: { greater_than: 0 }validates :input_cost,:cached_input_cost,diff --git a/plugins/discourse-ai/app/models/shared_ai_conversation.rb b/plugins/discourse-ai/app/models/shared_ai_conversation.rbindex a4485e06cfc..9ebe4a5ca9f 100644--- a/plugins/discourse-ai/app/models/shared_ai_conversation.rb+++ b/plugins/discourse-ai/app/models/shared_ai_conversation.rb@@ -199,7 +199,7 @@ class SharedAiConversation < ActiveRecord::Baseprivatedef populate_user_info!(posts)- users = User.where(id: posts.map(&:user_id).uniq).map { |u| [u.id, u] }.to_h+ users = User.where(id: posts.map(&:user_id).uniq).index_by(&:id)posts.each { |post| post.user = users[post.user_id] }enddiff --git a/plugins/discourse-ai/lib/ai_bot/response_http_streamer.rb b/plugins/discourse-ai/lib/ai_bot/response_http_streamer.rbindex cfb2fbebc45..565484bec5f 100644--- a/plugins/discourse-ai/lib/ai_bot/response_http_streamer.rb+++ b/plugins/discourse-ai/lib/ai_bot/response_http_streamer.rb@@ -117,7 +117,7 @@ module DiscourseAirescue StandardError => e# make it a tiny bit easier to debug in dev, this is tricky# multi-threaded code that exhibits various limitations in rails- p e if Rails.env.development? || Rails.env.test?+ p e if Rails.env.local?Discourse.warn_exception(e, message: "Discourse AI: Unable to stream reply")ensureio.closediff --git a/plugins/discourse-ai/lib/automation/llm_tool_triage.rb b/plugins/discourse-ai/lib/automation/llm_tool_triage.rbindex 58b9210d5b2..e8206da401b 100644--- a/plugins/discourse-ai/lib/automation/llm_tool_triage.rb+++ b/plugins/discourse-ai/lib/automation/llm_tool_triage.rb@@ -5,7 +5,7 @@ module DiscourseAidef self.handle(post:, tool_id:, automation: nil)tool = AiTool.find_by(id: tool_id)return if !tool- return if !tool.parameters.blank?+ return if tool.parameters.present?context = DiscourseAi::Personas::BotContext.new(post: post)diff --git a/plugins/discourse-ai/lib/automation/report_runner.rb b/plugins/discourse-ai/lib/automation/report_runner.rbindex d4d06b143b4..ea35e8091fa 100644--- a/plugins/discourse-ai/lib/automation/report_runner.rb+++ b/plugins/discourse-ai/lib/automation/report_runner.rb@@ -68,12 +68,7 @@ module DiscourseAi@receivers = []end@email_receivers = receivers&.filter { |r| r.include? "@" }- @title =- if title.present?- title- else- I18n.t("discourse_automation.scriptables.llm_report.title")- end+ @title = title.presence || I18n.t("discourse_automation.scriptables.llm_report.title")@model = LlmModel.find_by(id: model)@persona = AiPersona.find(persona_id).class_instance.new@category_ids = category_idsdiff --git a/plugins/discourse-ai/lib/completions/dialects/dialect.rb b/plugins/discourse-ai/lib/completions/dialects/dialect.rbindex c0d5e38b864..193e0a59ee4 100644--- a/plugins/discourse-ai/lib/completions/dialects/dialect.rb+++ b/plugins/discourse-ai/lib/completions/dialects/dialect.rb@@ -25,9 +25,7 @@ module DiscourseAidef dialect_for(llm_model)dialects = []- if Rails.env.test? || Rails.env.development?- dialects = [DiscourseAi::Completions::Dialects::Fake]- end+ dialects = [DiscourseAi::Completions::Dialects::Fake] if Rails.env.local?dialects = dialects.concat(all_dialects)diff --git a/plugins/discourse-ai/lib/completions/dialects/nova.rb b/plugins/discourse-ai/lib/completions/dialects/nova.rbindex 10098c2676f..5197d4c1c47 100644--- a/plugins/discourse-ai/lib/completions/dialects/nova.rb+++ b/plugins/discourse-ai/lib/completions/dialects/nova.rb@@ -111,7 +111,7 @@ module DiscourseAiconfig[:top_k] = ic[:top_k] if ic[:top_k]config[:stopSequences] = ic[:stop_sequences] if ic[:stop_sequences]- config.present? ? config : nil+ config.presenceenddef detect_format(mime_type)diff --git a/plugins/discourse-ai/lib/completions/endpoints/base.rb b/plugins/discourse-ai/lib/completions/endpoints/base.rbindex 0a304abbab3..f0f0bbc9702 100644--- a/plugins/discourse-ai/lib/completions/endpoints/base.rb+++ b/plugins/discourse-ai/lib/completions/endpoints/base.rb@@ -30,9 +30,7 @@ module DiscourseAiendpoints << DiscourseAi::Completions::Endpoints::Ollama if !Rails.env.production?- if Rails.env.test? || Rails.env.development?- endpoints << DiscourseAi::Completions::Endpoints::Fake- end+ endpoints << DiscourseAi::Completions::Endpoints::Fake if Rails.env.local?endpoints.detect(-> { raise DiscourseAi::Completions::Llm::UNKNOWN_MODEL }) do |ek|ek.can_contact?(provider_name)@@ -453,11 +451,7 @@ module DiscourseAiif xml_stripperresponse_data.map! do |partial|stripped = (xml_stripper << partial) if partial.is_a?(String)- if stripped.present?- stripped- else- partial- end+ stripped.presence || partialendresponse_data << xml_stripper.finishenddiff --git a/plugins/discourse-ai/lib/embeddings/semantic_related.rb b/plugins/discourse-ai/lib/embeddings/semantic_related.rbindex 869e4b5bfe0..5ffcdbb59dc 100644--- a/plugins/discourse-ai/lib/embeddings/semantic_related.rb+++ b/plugins/discourse-ai/lib/embeddings/semantic_related.rb@@ -50,11 +50,11 @@ module DiscourseAidef results_ttl(topic)case topic.created_at- when 6.hour.ago..Time.now+ when 6.hours.ago..Time.now15.minutes- when 3.day.ago..6.hour.ago+ when 3.days.ago..6.hours.ago1.hour- when 15.days.ago..3.day.ago+ when 15.days.ago..3.days.ago12.hourselse1.weekdiff --git a/plugins/discourse-ai/lib/embeddings/semantic_search.rb b/plugins/discourse-ai/lib/embeddings/semantic_search.rbindex 3f6f5ba8f07..e33080c2d44 100644--- a/plugins/discourse-ai/lib/embeddings/semantic_search.rb+++ b/plugins/discourse-ai/lib/embeddings/semantic_search.rb@@ -239,11 +239,7 @@ module DiscourseAiid: SiteSetting.ai_embeddings_semantic_search_hyde_persona,)&.default_llm_id- if persona_llm_id.present?- persona_llm_id- else- SiteSetting.ai_default_llm_model.to_i || LlmModel.last&.id- end+ persona_llm_id.presence || SiteSetting.ai_default_llm_model.to_i || LlmModel.last&.idendprivatediff --git a/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rb b/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rbindex 5fdfb76ef1b..ddaaaaf1be7 100644--- a/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rb+++ b/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rb@@ -112,12 +112,12 @@ module DiscourseAielsecategories =if categories_json = json.dig("grouped_search_result", "extra", "categories")- categories_json.map { |c| [c["id"], c] }.to_h+ categories_json.index_by { _1["id"] }elseself.class.categoriesend- topics = (json["topics"]).map { |t| [t["id"], t] }.to_h+ topics = (json["topics"]).index_by { _1["id"] }format_results(posts, args: parameters) do |post|topic = topics[post["topic_id"]]diff --git a/plugins/discourse-ai/lib/personas/tools/setting_context.rb b/plugins/discourse-ai/lib/personas/tools/setting_context.rbindex e8b390c61fa..c37f2c5d4e6 100644--- a/plugins/discourse-ai/lib/personas/tools/setting_context.rb+++ b/plugins/discourse-ai/lib/personas/tools/setting_context.rb@@ -130,7 +130,7 @@ module DiscourseAi"--heading",success_status_codes: [0, 1],)- if !result.blank?+ if result.present?path = search_pathbreakend@@ -145,7 +145,7 @@ module DiscourseAifiltered = []rows.each do |row|- if !filtered.blank?+ if filtered.present?break if row.match(/^\s*/)[0].length <= leading_spacesendfiltered << rowdiff --git a/plugins/discourse-ai/lib/personas/tools/tool.rb b/plugins/discourse-ai/lib/personas/tools/tool.rbindex 858750fc15d..da535e54262 100644--- a/plugins/discourse-ai/lib/personas/tools/tool.rb+++ b/plugins/discourse-ai/lib/personas/tools/tool.rb@@ -8,7 +8,7 @@ module DiscourseAi# This general limit is mainly a security feature to avoid tools# forcing infinite downloads or causing memory exhaustion.# The limit is somewhat arbitrary and can be increased in future if needed.- MAX_RESPONSE_BODY_LENGTH = 30.megabyte+ MAX_RESPONSE_BODY_LENGTH = 30.megabytesclass << selfdef signature@@ -87,7 +87,7 @@ module DiscourseAienddef options- result = HashWithIndifferentAccess.new+ result = ActiveSupport::HashWithIndifferentAccess.newself.class.accepted_options.each do |option|val = @persona_options[option.name]if valdiff --git a/plugins/discourse-ai/spec/configuration/feature_spec.rb b/plugins/discourse-ai/spec/configuration/feature_spec.rbindex ba402b78598..eeacd009c8d 100644--- a/plugins/discourse-ai/spec/configuration/feature_spec.rb+++ b/plugins/discourse-ai/spec/configuration/feature_spec.rb@@ -61,7 +61,7 @@ RSpec.describe DiscourseAi::Configuration::Feature doendcontext "with translation module" do- fab!(:translation_model) { Fabricate(:llm_model) }+ fab!(:translation_model, :llm_model)let(:ai_feature) dodescribed_class.new(diff --git a/plugins/discourse-ai/spec/fabricators/llm_quota_usage_fabricator.rb b/plugins/discourse-ai/spec/fabricators/llm_quota_usage_fabricator.rbindex 439cf739496..cf6e14be8e4 100644--- a/plugins/discourse-ai/spec/fabricators/llm_quota_usage_fabricator.rb+++ b/plugins/discourse-ai/spec/fabricators/llm_quota_usage_fabricator.rb@@ -7,5 +7,5 @@ Fabricator(:llm_quota_usage) dooutput_tokens_used { 0 }usages { 0 }started_at { Time.current }- reset_at { Time.current + 1.day }+ reset_at { 1.day.from_now }enddiff --git a/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb b/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rbindex 3ea8b0c41ca..db6cbf54568 100644--- a/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/detect_translate_post_spec.rb@@ -110,7 +110,7 @@ describe Jobs::DetectTranslatePost dofab!(:private_topic) { Fabricate(:topic, category: private_category) }fab!(:private_post) { Fabricate(:post, topic: private_topic) }- fab!(:personal_pm_topic) { Fabricate(:private_message_topic) }+ fab!(:personal_pm_topic, :private_message_topic)fab!(:personal_pm_post) { Fabricate(:post, topic: personal_pm_topic) }fab!(:group_pm_topic) dodiff --git a/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb b/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rbindex 4a8bca9d368..33b7c60113f 100644--- a/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/detect_translate_topic_spec.rb@@ -100,7 +100,7 @@ describe Jobs::DetectTranslateTopic dofab!(:private_category) { Fabricate(:private_category, group: Group[:staff]) }fab!(:private_topic) { Fabricate(:topic, category: private_category) }- fab!(:personal_pm_topic) { Fabricate(:private_message_topic) }+ fab!(:personal_pm_topic, :private_message_topic)fab!(:group_pm_topic) doFabricate(:group_private_message_topic, recipient_group: Fabricate(:group))diff --git a/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb b/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rbindex 3cd861ce7b4..9f08fde9b1d 100644--- a/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/digest_rag_upload_spec.rb@@ -3,7 +3,7 @@RSpec.describe Jobs::DigestRagUpload dosubject(:job) { described_class.new }- fab!(:persona) { Fabricate(:ai_persona) }+ fab!(:persona, :ai_persona)fab!(:upload) { Fabricate(:upload, extension: "txt") }fab!(:image_upload) { Fabricate(:upload, extension: "png") }let(:document_file) { StringIO.new("some text" * 200) }diff --git a/plugins/discourse-ai/spec/jobs/regular/fast_track_topic_gist_spec.rb b/plugins/discourse-ai/spec/jobs/regular/fast_track_topic_gist_spec.rbindex a64ecd08269..fa4e6cd1246 100644--- a/plugins/discourse-ai/spec/jobs/regular/fast_track_topic_gist_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/fast_track_topic_gist_spec.rb@@ -4,7 +4,7 @@ RSpec.describe Jobs::FastTrackTopicGist dosubject(:job) { described_class.new }describe "#execute" do- fab!(:topic_1) { Fabricate(:topic) }+ fab!(:topic_1, :topic)fab!(:post_1) { Fabricate(:post, topic: topic_1, post_number: 1) }fab!(:post_2) { Fabricate(:post, topic: topic_1, post_number: 2) }diff --git a/plugins/discourse-ai/spec/jobs/regular/generate_rag_embeddings_spec.rb b/plugins/discourse-ai/spec/jobs/regular/generate_rag_embeddings_spec.rbindex 60c14169168..2c5fdd9fd2c 100644--- a/plugins/discourse-ai/spec/jobs/regular/generate_rag_embeddings_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/generate_rag_embeddings_spec.rb@@ -6,7 +6,7 @@ RSpec.describe Jobs::GenerateRagEmbeddings dobefore { enable_current_plugin }describe "#execute" do- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)let(:expected_embedding) { [0.0038493] * vector_def.dimensions }diff --git a/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb b/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rbindex 1670369ab62..8c0a863a57a 100644--- a/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/localize_posts_spec.rb@@ -145,7 +145,7 @@ describe Jobs::LocalizePosts dofab!(:public_post) { Fabricate(:post, locale: "es") }- fab!(:personal_pm_topic) { Fabricate(:private_message_topic) }+ fab!(:personal_pm_topic, :private_message_topic)fab!(:personal_pm_post) { Fabricate(:post, topic: personal_pm_topic, locale: "es") }fab!(:group)diff --git a/plugins/discourse-ai/spec/jobs/regular/stream_composer_helper_spec.rb b/plugins/discourse-ai/spec/jobs/regular/stream_composer_helper_spec.rbindex 9ee821fa412..2a63c2f0495 100644--- a/plugins/discourse-ai/spec/jobs/regular/stream_composer_helper_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/stream_composer_helper_spec.rb@@ -10,7 +10,7 @@ RSpec.describe Jobs::StreamComposerHelper dodescribe "#execute" dolet!(:input) { "I liek to eet pie fur brakefast becuz it is delishus." }- fab!(:user) { Fabricate(:leader) }+ fab!(:user, :leader)before doGroup.find(Group::AUTO_GROUPS[:trust_level_3]).add(user)diff --git a/plugins/discourse-ai/spec/jobs/regular/stream_post_helper_spec.rb b/plugins/discourse-ai/spec/jobs/regular/stream_post_helper_spec.rbindex 7a7442660b4..952bac0019a 100644--- a/plugins/discourse-ai/spec/jobs/regular/stream_post_helper_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/stream_post_helper_spec.rb@@ -18,7 +18,7 @@ RSpec.describe Jobs::StreamPostHelper do"I like to eat pie. It is a very good dessert. Some people are wasteful by throwing pie at others but I do not do that. I always eat the pie.",)end- fab!(:user) { Fabricate(:leader) }+ fab!(:user, :leader)before doGroup.find(Group::AUTO_GROUPS[:trust_level_3]).add(user)diff --git a/plugins/discourse-ai/spec/jobs/regular/stream_topic_ai_summary_spec.rb b/plugins/discourse-ai/spec/jobs/regular/stream_topic_ai_summary_spec.rbindex 20a829b67dc..cc2f56e0a87 100644--- a/plugins/discourse-ai/spec/jobs/regular/stream_topic_ai_summary_spec.rb+++ b/plugins/discourse-ai/spec/jobs/regular/stream_topic_ai_summary_spec.rb@@ -9,7 +9,7 @@ RSpec.describe Jobs::StreamTopicAiSummary dofab!(:topic) { Fabricate(:topic, highest_post_number: 2) }fab!(:post_1) { Fabricate(:post, topic: topic, post_number: 1) }fab!(:post_2) { Fabricate(:post, topic: topic, post_number: 2) }- fab!(:user) { Fabricate(:leader) }+ fab!(:user, :leader)before doGroup.find(Group::AUTO_GROUPS[:trust_level_3]).add(user)diff --git a/plugins/discourse-ai/spec/jobs/scheduled/embeddings_backfill_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/embeddings_backfill_spec.rbindex 822da388b8e..8db75fae192 100644--- a/plugins/discourse-ai/spec/jobs/scheduled/embeddings_backfill_spec.rb+++ b/plugins/discourse-ai/spec/jobs/scheduled/embeddings_backfill_spec.rb@@ -2,7 +2,7 @@RSpec.describe Jobs::EmbeddingsBackfill dofab!(:second_topic) do- topic = Fabricate(:topic, created_at: 1.year.ago, bumped_at: 2.day.ago)+ topic = Fabricate(:topic, created_at: 1.year.ago, bumped_at: 2.days.ago)Fabricate(:post, topic: topic)topicend@@ -14,13 +14,13 @@ RSpec.describe Jobs::EmbeddingsBackfill doendfab!(:third_topic) do- topic = Fabricate(:topic, created_at: 1.year.ago, bumped_at: 3.day.ago)+ topic = Fabricate(:topic, created_at: 1.year.ago, bumped_at: 3.days.ago)Fabricate(:post, topic: topic)topicend- fab!(:vector_def) { Fabricate(:embedding_definition) }- fab!(:vector_def2) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)+ fab!(:vector_def2, :embedding_definition)fab!(:embedding_array) { Array.new(1024) { 1 } }before dodiff --git a/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rbindex d74ae6cd5f4..21bc0451e6b 100644--- a/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb+++ b/plugins/discourse-ai/spec/jobs/scheduled/posts_locale_detection_backfill_spec.rb@@ -44,8 +44,8 @@ describe Jobs::PostsLocaleDetectionBackfill dopost_3 = Fabricate(:post, locale: nil)post.update!(updated_at: 3.days.ago)- post_2.update!(updated_at: 2.day.ago)- post_3.update!(updated_at: 4.day.ago)+ post_2.update!(updated_at: 2.days.ago)+ post_3.update!(updated_at: 4.days.ago)SiteSetting.ai_translation_backfill_hourly_rate = 12@@ -89,7 +89,7 @@ describe Jobs::PostsLocaleDetectionBackfill dofab!(:group_pm_topic) { Fabricate(:private_message_topic, allowed_groups: [group]) }fab!(:group_pm_post) { Fabricate(:post, topic: group_pm_topic, locale: nil) }- fab!(:pm_topic) { Fabricate(:private_message_topic) }+ fab!(:pm_topic, :private_message_topic)fab!(:pm_post) { Fabricate(:post, topic: pm_topic, locale: nil) }before { SiteSetting.ai_translation_backfill_limit_to_public_content = true }diff --git a/plugins/discourse-ai/spec/jobs/scheduled/remove_orphaned_embeddings_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/remove_orphaned_embeddings_spec.rbindex de620701fa5..fba1695e0fd 100644--- a/plugins/discourse-ai/spec/jobs/scheduled/remove_orphaned_embeddings_spec.rb+++ b/plugins/discourse-ai/spec/jobs/scheduled/remove_orphaned_embeddings_spec.rb@@ -7,7 +7,7 @@ RSpec.describe Jobs::RemoveOrphanedEmbeddings dodescribe "#execute" dofab!(:embedding_definition)- fab!(:embedding_definition_2) { Fabricate(:embedding_definition) }+ fab!(:embedding_definition_2, :embedding_definition)fab!(:topic)fab!(:post)diff --git a/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb b/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rbindex 518c00d96ae..0597dab0831 100644--- a/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb+++ b/plugins/discourse-ai/spec/jobs/scheduled/topics_locale_detection_backfill_spec.rb@@ -44,8 +44,8 @@ describe Jobs::TopicsLocaleDetectionBackfill dotopic_3 = Fabricate(:topic, locale: nil)topic.update!(updated_at: 3.days.ago)- topic_2.update!(updated_at: 2.day.ago)- topic_3.update!(updated_at: 4.day.ago)+ topic_2.update!(updated_at: 2.days.ago)+ topic_3.update!(updated_at: 4.days.ago)SiteSetting.ai_translation_backfill_hourly_rate = 12@@ -87,7 +87,7 @@ describe Jobs::TopicsLocaleDetectionBackfill dofab!(:group)fab!(:group_pm_topic) { Fabricate(:private_message_topic, allowed_groups: [group]) }- fab!(:pm_topic) { Fabricate(:private_message_topic) }+ fab!(:pm_topic, :private_message_topic)fab!(:public_topic) { Fabricate(:topic, locale: nil) }diff --git a/plugins/discourse-ai/spec/lib/completions/dialects/gemini_spec.rb b/plugins/discourse-ai/spec/lib/completions/dialects/gemini_spec.rbindex e4d50ee72d2..6052d0c6a6e 100644--- a/plugins/discourse-ai/spec/lib/completions/dialects/gemini_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/dialects/gemini_spec.rb@@ -3,7 +3,7 @@require_relative "dialect_context"RSpec.describe DiscourseAi::Completions::Dialects::Gemini do- fab!(:model) { Fabricate(:gemini_model) }+ fab!(:model, :gemini_model)let(:context) { DialectContext.new(described_class, model) }before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/lib/completions/dialects/mistral_spec.rb b/plugins/discourse-ai/spec/lib/completions/dialects/mistral_spec.rbindex 0cce09d5efa..12013840d63 100644--- a/plugins/discourse-ai/spec/lib/completions/dialects/mistral_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/dialects/mistral_spec.rb@@ -3,7 +3,7 @@require_relative "dialect_context"RSpec.describe DiscourseAi::Completions::Dialects::Mistral do- fab!(:model) { Fabricate(:mistral_model) }+ fab!(:model, :mistral_model)let(:context) { DialectContext.new(described_class, model) }let(:image100x100) { plugin_file_from_fixtures("100x100.jpg") }let(:upload100x100) dodiff --git a/plugins/discourse-ai/spec/lib/completions/dialects/ollama_spec.rb b/plugins/discourse-ai/spec/lib/completions/dialects/ollama_spec.rbindex e0a2e8e1808..22db5028c9e 100644--- a/plugins/discourse-ai/spec/lib/completions/dialects/ollama_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/dialects/ollama_spec.rb@@ -3,7 +3,7 @@require_relative "dialect_context"RSpec.describe DiscourseAi::Completions::Dialects::Ollama do- fab!(:model) { Fabricate(:ollama_model) }+ fab!(:model, :ollama_model)let(:context) { DialectContext.new(described_class, model) }let(:dialect_class) { DiscourseAi::Completions::Dialects::Dialect.dialect_for(model) }diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rbindex 8d95be58183..a0eab17436d 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/aws_bedrock_spec.rb@@ -11,7 +11,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::AwsBedrock dosubject(:endpoint) { described_class.new(model) }fab!(:user)- fab!(:model) { Fabricate(:bedrock_model) }+ fab!(:model, :bedrock_model)let(:bedrock_mock) { BedrockMock.new(endpoint) }diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/ollama_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/ollama_spec.rbindex 3531a4a1914..4d2def80ace 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/ollama_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/ollama_spec.rb@@ -127,7 +127,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Ollama dosubject(:endpoint) { described_class.new(model) }fab!(:user)- fab!(:model) { Fabricate(:ollama_model) }+ fab!(:model, :ollama_model)let(:ollama_mock) { OllamaMock.new(endpoint) }diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rbindex 7297e56a664..21902795ee3 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/open_ai_spec.rb@@ -151,7 +151,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::OpenAi dosubject(:endpoint) { described_class.new(model) }fab!(:user)- fab!(:model) { Fabricate(:llm_model) }+ fab!(:model, :llm_model)let(:echo_tool) do{diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/samba_nova_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/samba_nova_spec.rbindex bacff00d086..b983dca1809 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/samba_nova_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/samba_nova_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe DiscourseAi::Completions::Endpoints::SambaNova do- fab!(:llm_model) { Fabricate(:samba_nova_model) }+ fab!(:llm_model, :samba_nova_model)let(:llm) { llm_model.to_llm }before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rbindex 27bdd4feb42..d586864463e 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rb@@ -65,7 +65,7 @@ endRSpec.describe DiscourseAi::Completions::Endpoints::Vllm dosubject(:endpoint) { described_class.new(llm_model) }- fab!(:llm_model) { Fabricate(:vllm_model) }+ fab!(:llm_model, :vllm_model)fab!(:user)let(:llm) { DiscourseAi::Completions::Llm.proxy(llm_model) }diff --git a/plugins/discourse-ai/spec/lib/completions/llm_spec.rb b/plugins/discourse-ai/spec/lib/completions/llm_spec.rbindex 3759a627972..814a4053e1c 100644--- a/plugins/discourse-ai/spec/lib/completions/llm_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/llm_spec.rb@@ -11,7 +11,7 @@ RSpec.describe DiscourseAi::Completions::Llm doendfab!(:user)- fab!(:model) { Fabricate(:llm_model) }+ fab!(:model, :llm_model)before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb b/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rbindex 44e97cc97d1..7aa106fc238 100644--- a/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/prompt_messages_builder_spec.rb@@ -4,8 +4,8 @@ describe DiscourseAi::Completions::PromptMessagesBuilder dolet(:builder) { DiscourseAi::Completions::PromptMessagesBuilder.new }fab!(:user)fab!(:admin)- fab!(:bot_user) { Fabricate(:user) }- fab!(:other_user) { Fabricate(:user) }+ fab!(:bot_user, :user)+ fab!(:other_user, :user)fab!(:image_upload1) doFabricate(:upload, user: user, original_filename: "image.png", extension: "png")@@ -175,7 +175,7 @@ describe DiscourseAi::Completions::PromptMessagesBuilder doFabricate(:chat_message, chat_channel: dm_channel, user: user, message: "How are you?")end- fab!(:public_channel) { Fabricate(:category_channel) }+ fab!(:public_channel, :category_channel)fab!(:public_message1) doFabricate(:chat_message, chat_channel: public_channel, user: user, message: "Hello everyone")end@@ -312,8 +312,8 @@ describe DiscourseAi::Completions::PromptMessagesBuilder doenddescribe "upload limits in messages_from_chat" do- fab!(:test_channel) { Fabricate(:category_channel) }- fab!(:test_user) { Fabricate(:user) }+ fab!(:test_channel, :category_channel)+ fab!(:test_user, :user)# Create MAX_CHAT_UPLOADS + 1 uploadsfab!(:uploads) dodiff --git a/plugins/discourse-ai/spec/lib/discourse_automation/llm_persona_triage_spec.rb b/plugins/discourse-ai/spec/lib/discourse_automation/llm_persona_triage_spec.rbindex 57ca6d12698..b7f3ecddef4 100644--- a/plugins/discourse-ai/spec/lib/discourse_automation/llm_persona_triage_spec.rb+++ b/plugins/discourse-ai/spec/lib/discourse_automation/llm_persona_triage_spec.rb@@ -4,7 +4,7 @@ return if !defined?(DiscourseAutomation)describe DiscourseAi::Automation::LlmPersonaTriage dofab!(:user)- fab!(:bot_user) { Fabricate(:user) }+ fab!(:bot_user, :user)fab!(:llm_model) { Fabricate(:anthropic_model, name: "claude-3-opus", enabled_chat_bot: true) }@@ -272,8 +272,8 @@ describe DiscourseAi::Automation::LlmPersonaTriage dodescribe "LLM Persona Triage with Chat Message Creation" dofab!(:user)- fab!(:bot_user) { Fabricate(:user) }- fab!(:chat_channel) { Fabricate(:category_channel) }+ fab!(:bot_user, :user)+ fab!(:chat_channel, :category_channel)fab!(:custom_tool) doAiTool.create!(diff --git a/plugins/discourse-ai/spec/lib/discourse_automation/llm_tool_triage_spec.rb b/plugins/discourse-ai/spec/lib/discourse_automation/llm_tool_triage_spec.rbindex 0b3cdeef84a..f7981ab33b5 100644--- a/plugins/discourse-ai/spec/lib/discourse_automation/llm_tool_triage_spec.rb+++ b/plugins/discourse-ai/spec/lib/discourse_automation/llm_tool_triage_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe DiscourseAi::Automation::LlmToolTriage do- fab!(:solver) { Fabricate(:user) }+ fab!(:solver, :user)fab!(:new_user) { Fabricate(:user, trust_level: TrustLevel[0], created_at: 1.day.ago) }fab!(:topic) { Fabricate(:topic, user: new_user) }fab!(:post) { Fabricate(:post, topic: topic, user: new_user, raw: "How do I reset my password?") }diff --git a/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb b/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rbindex f31489da4b9..f6d8957da62 100644--- a/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb+++ b/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb@@ -4,8 +4,8 @@ return if !defined?(DiscourseAutomation)describe DiscourseAi::Automation::LlmTriage dofab!(:category)- fab!(:reply_user) { Fabricate(:user) }- fab!(:personal_message) { Fabricate(:private_message_topic) }+ fab!(:reply_user, :user)+ fab!(:personal_message, :private_message_topic)let(:canned_reply_text) { "Hello, this is a reply" }let(:automation) { Fabricate(:automation, script: "llm_triage", enabled: true) }diff --git a/plugins/discourse-ai/spec/lib/inferred_concepts/applier_spec.rb b/plugins/discourse-ai/spec/lib/inferred_concepts/applier_spec.rbindex b0eeb952225..ac549c40cce 100644--- a/plugins/discourse-ai/spec/lib/inferred_concepts/applier_spec.rb+++ b/plugins/discourse-ai/spec/lib/inferred_concepts/applier_spec.rb@@ -8,7 +8,7 @@ RSpec.describe DiscourseAi::InferredConcepts::Applier dofab!(:user) { Fabricate(:user, username: "dev_user") }fab!(:concept1) { Fabricate(:inferred_concept, name: "programming") }fab!(:concept2) { Fabricate(:inferred_concept, name: "testing") }- fab!(:llm_model) { Fabricate(:fake_model) }+ fab!(:llm_model, :fake_model)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/lib/inferred_concepts/finder_spec.rb b/plugins/discourse-ai/spec/lib/inferred_concepts/finder_spec.rbindex 0db814c84e3..d9176b408ed 100644--- a/plugins/discourse-ai/spec/lib/inferred_concepts/finder_spec.rb+++ b/plugins/discourse-ai/spec/lib/inferred_concepts/finder_spec.rb@@ -7,7 +7,7 @@ RSpec.describe DiscourseAi::InferredConcepts::Finder dofab!(:post) { Fabricate(:post, like_count: 10) }fab!(:concept1) { Fabricate(:inferred_concept, name: "programming") }fab!(:concept2) { Fabricate(:inferred_concept, name: "testing") }- fab!(:llm_model) { Fabricate(:fake_model) }+ fab!(:llm_model, :fake_model)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rbindex 69f073fb95a..e64d8af5947 100644--- a/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/ai_bot/entry_point_spec.rb@@ -6,7 +6,7 @@ RSpec.describe DiscourseAi::AiBot::EntryPoint dodescribe "#inject_into" dodescribe "subscribes to the post_created event" dofab!(:admin)- fab!(:bot_allowed_group) { Fabricate(:group) }+ fab!(:bot_allowed_group, :group)fab!(:gpt_4) { Fabricate(:llm_model, name: "gpt-4") }let(:gpt_bot) { gpt_4.reload.user }diff --git a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rbindex fe9e0306fb6..1c57b5fd46d 100644--- a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb@@ -11,7 +11,7 @@ RSpec.describe DiscourseAi::AiBot::Playground doname: "claude-2",)end- fab!(:opus_model) { Fabricate(:anthropic_model) }+ fab!(:opus_model, :anthropic_model)fab!(:bot_user) doenable_current_plugin@@ -310,7 +310,7 @@ RSpec.describe DiscourseAi::AiBot::Playground doendcontext "with chat channels" do- fab!(:channel) { Fabricate(:chat_channel) }+ fab!(:channel, :chat_channel)fab!(:membership) doFabricate(:user_chat_channel_membership, user: user, chat_channel: channel)diff --git a/plugins/discourse-ai/spec/lib/modules/ai_helper/chat_thread_titler_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_helper/chat_thread_titler_spec.rbindex 2b68497b0ae..4c39556f6de 100644--- a/plugins/discourse-ai/spec/lib/modules/ai_helper/chat_thread_titler_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/ai_helper/chat_thread_titler_spec.rb@@ -3,7 +3,7 @@RSpec.describe DiscourseAi::AiHelper::ChatThreadTitler dosubject(:titler) { described_class.new(thread) }- fab!(:thread) { Fabricate(:chat_thread) }+ fab!(:thread, :chat_thread)fab!(:chat_message) { Fabricate(:chat_message, thread: thread) }fab!(:user)diff --git a/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rbindex 9f14ca98c0e..6e665f12420 100644--- a/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/ai_helper/entry_point_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe DiscourseAi::AiHelper::EntryPoint do- fab!(:english_user) { Fabricate(:user) }+ fab!(:english_user, :user)fab!(:french_user) { Fabricate(:user, locale: "fr") }before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/lib/modules/ai_helper/semantic_categorizer_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_helper/semantic_categorizer_spec.rbindex effec0e9e9f..4c44b580ec9 100644--- a/plugins/discourse-ai/spec/lib/modules/ai_helper/semantic_categorizer_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/ai_helper/semantic_categorizer_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: trueRSpec.describe DiscourseAi::AiHelper::SemanticCategorizer do- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)fab!(:user)- fab!(:muted_category) { Fabricate(:category) }+ fab!(:muted_category, :category)fab!(:category_mute) doCategoryUser.create!(user: user,diff --git a/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb b/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rbindex 58d01d77faa..ee1094e9b7e 100644--- a/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/automation/report_context_generator_spec.rb@@ -5,7 +5,7 @@ module DiscourseAidescribe ReportContextGenerator dodescribe ".generate" dofab!(:private_message_post)- fab!(:post_in_other_category) { Fabricate(:post) }+ fab!(:post_in_other_category, :post)fab!(:category)fab!(:topic) { Fabricate(:topic, category: category) }@@ -23,7 +23,7 @@ module DiscourseAiendfab!(:tag)- fab!(:tag2) { Fabricate(:tag) }+ fab!(:tag2, :tag)fab!(:topic_with_tag) { Fabricate(:topic, tags: [tag, tag2]) }fab!(:post_with_tag) { Fabricate(:post, topic: topic_with_tag) }@@ -49,7 +49,7 @@ module DiscourseAiit "will correctly denote solved topics" doFabricate(:solved_topic, topic: topic_with_likes, answer_post: post_with_likes2)- context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day)+ context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)expect(context).to include("solved: true")expect(context).to include("solution: true")@@ -59,28 +59,28 @@ module DiscourseAiit "will exclude non visible topics" dopost_with_likes3.topic.update(visible: false)- context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day)+ context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)expect(context).not_to include("topic_id: #{topic_with_likes.id}")endit "always includes info from last posts on topic" docontext =- ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day, max_posts: 1)+ ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days, max_posts: 1)expect(context).to include("...")expect(context).to include("post_number: 3")endit "includes a summary" do- context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day)+ context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)expect(context).to include("New posts: 8")expect(context).to include("New topics: 5")endit "orders so most liked are first" do- context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day)+ context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)regex = "topic_id: #{topic_with_likes.id}.*topic_id: #{long_post.topic.id}"expect(context).to match(Regexp.new(regex, Regexp::MULTILINE))@@ -90,7 +90,7 @@ module DiscourseAicontext =ReportContextGenerator.generate(start_date: 1.day.ago,- duration: 2.day,+ duration: 2.days,prioritized_group_ids: [group.id],allow_secure_categories: true,max_posts: 1,@@ -102,7 +102,7 @@ module DiscourseAiendit "can generate context (excluding PMs)" do- context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.day)+ context = ReportContextGenerator.generate(start_date: 1.day.ago, duration: 2.days)expect(context).to include(post_in_other_category.topic.title)expect(context).to include(topic.title)@@ -114,7 +114,7 @@ module DiscourseAicontext =ReportContextGenerator.generate(start_date: 1.day.ago,- duration: 2.day,+ duration: 2.days,tags: [tag.name],)@@ -129,7 +129,7 @@ module DiscourseAicontext =ReportContextGenerator.generate(start_date: 1.day.ago,- duration: 2.day,+ duration: 2.days,allow_secure_categories: true,)expect(context).to include(post_in_other_category.topic.title)@@ -142,7 +142,7 @@ module DiscourseAicontext =ReportContextGenerator.generate(start_date: 1.day.ago,- duration: 2.day,+ duration: 2.days,category_ids: [category.id],)diff --git a/plugins/discourse-ai/spec/lib/modules/automation/report_runner_spec.rb b/plugins/discourse-ai/spec/lib/modules/automation/report_runner_spec.rbindex d1b1b50221a..bd955618a02 100644--- a/plugins/discourse-ai/spec/lib/modules/automation/report_runner_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/automation/report_runner_spec.rb@@ -4,7 +4,7 @@ module DiscourseAimodule Automationdescribe ReportRunner dofab!(:user)- fab!(:receiver) { Fabricate(:user) }+ fab!(:receiver, :user)fab!(:post) { Fabricate(:post, user: user) }fab!(:group)fab!(:secure_category) { Fabricate(:private_category, group: group) }diff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/entry_point_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/entry_point_spec.rbindex ba36534554f..c748cb3cb5c 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/entry_point_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/entry_point_spec.rb@@ -61,7 +61,7 @@ describe DiscourseAi::Embeddings::EntryPoint dofab!(:category)fab!(:normal_topic_1) { Fabricate(:topic, category: category) }fab!(:normal_topic_2) { Fabricate(:topic, category: category) }- fab!(:private_topic) { Fabricate(:private_message_topic) }+ fab!(:private_topic, :private_message_topic)let(:query) { "title\n\nraw" }diff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rbindex 6d7cec65b2b..c8da9a0d480 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/jobs/generate_embeddings_spec.rb@@ -3,7 +3,7 @@RSpec.describe Jobs::GenerateEmbeddings dosubject(:job) { described_class.new }- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/schema_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/schema_spec.rbindex 2a2956ee76c..0ce006bce0c 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/schema_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/schema_spec.rb@@ -3,7 +3,7 @@RSpec.describe DiscourseAi::Embeddings::Schema dosubject(:posts_schema) { described_class.for(Post) }- fab!(:vector_def) { Fabricate(:cloudflare_embedding_def) }+ fab!(:vector_def, :cloudflare_embedding_def)let(:embeddings) { [0.0038490295] * vector_def.dimensions }fab!(:post) { Fabricate(:post, post_number: 1) }let(:digest) { OpenSSL::Digest.hexdigest("SHA1", "test") }@@ -33,7 +33,7 @@ RSpec.describe DiscourseAi::Embeddings::Schema doenddescribe "similarity searches" do- fab!(:post_2) { Fabricate(:post) }+ fab!(:post_2, :post)let(:similar_embeddings) { [0.0038490294] * vector_def.dimensions }describe "#symmetric_similarity_search" dodiff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_related_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_related_spec.rbindex b17f069bca3..06d84d8b118 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_related_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_related_spec.rb@@ -3,17 +3,17 @@describe DiscourseAi::Embeddings::SemanticRelated dosubject(:semantic_related) { described_class.new }- fab!(:target) { Fabricate(:topic) }- fab!(:normal_topic_1) { Fabricate(:topic) }- fab!(:normal_topic_2) { Fabricate(:topic) }- fab!(:normal_topic_3) { Fabricate(:topic) }+ fab!(:target, :topic)+ fab!(:normal_topic_1, :topic)+ fab!(:normal_topic_2, :topic)+ fab!(:normal_topic_3, :topic)fab!(:unlisted_topic) { Fabricate(:topic, visible: false) }- fab!(:private_topic) { Fabricate(:private_message_topic) }+ fab!(:private_topic, :private_message_topic)fab!(:secured_category) { Fabricate(:category, read_restricted: true) }fab!(:secured_category_topic) { Fabricate(:topic, category: secured_category) }fab!(:closed_topic) { Fabricate(:topic, closed: true) }- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_search_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_search_spec.rbindex 38bf9f357e7..9923c714884 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_search_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_search_spec.rb@@ -5,7 +5,7 @@ RSpec.describe DiscourseAi::Embeddings::SemanticSearch dofab!(:post)fab!(:user)- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)let(:query) { "test_query" }diff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_topic_query_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_topic_query_spec.rbindex d5ebe9d7b1c..afdc0d2402f 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_topic_query_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/semantic_topic_query_spec.rb@@ -9,9 +9,9 @@ describe DiscourseAi::Embeddings::EntryPoint dodescribe "#list_semantic_related_topics" dosubject(:topic_query) { DiscourseAi::Embeddings::SemanticTopicQuery.new(user) }- fab!(:target) { Fabricate(:topic) }+ fab!(:target, :topic)- fab!(:vector_def) { Fabricate(:cloudflare_embedding_def) }+ fab!(:vector_def, :cloudflare_embedding_def)before doSiteSetting.ai_embeddings_enabled = true@@ -44,7 +44,7 @@ describe DiscourseAi::Embeddings::EntryPoint doendcontext "when the semantic search returns a private topic" do- fab!(:private_topic) { Fabricate(:private_message_topic) }+ fab!(:private_topic, :private_message_topic)before { seed_embeddings([private_topic]) }@@ -101,9 +101,9 @@ describe DiscourseAi::Embeddings::EntryPoint doendcontext "when the semantic search returns public topics" do- fab!(:normal_topic_1) { Fabricate(:topic) }- fab!(:normal_topic_2) { Fabricate(:topic) }- fab!(:normal_topic_3) { Fabricate(:topic) }+ fab!(:normal_topic_1, :topic)+ fab!(:normal_topic_2, :topic)+ fab!(:normal_topic_3, :topic)fab!(:closed_topic) { Fabricate(:topic, closed: true) }before { seed_embeddings([closed_topic, normal_topic_1, normal_topic_2, normal_topic_3]) }@@ -125,8 +125,8 @@ describe DiscourseAi::Embeddings::EntryPoint doendcontext "with semantic_related_topics_query modifier registered" do- fab!(:included_topic) { Fabricate(:topic) }- fab!(:excluded_topic) { Fabricate(:topic) }+ fab!(:included_topic, :topic)+ fab!(:excluded_topic, :topic)before { seed_embeddings([included_topic, excluded_topic]) }diff --git a/plugins/discourse-ai/spec/lib/modules/embeddings/vector_spec.rb b/plugins/discourse-ai/spec/lib/modules/embeddings/vector_spec.rbindex 685c8fe9b9f..6a625a9f07e 100644--- a/plugins/discourse-ai/spec/lib/modules/embeddings/vector_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/embeddings/vector_spec.rb@@ -83,7 +83,7 @@ RSpec.describe DiscourseAi::Embeddings::Vector doenddescribe "#gen_bulk_reprensentations" do- fab!(:topic_2) { Fabricate(:topic) }+ fab!(:topic_2, :topic)fab!(:post_2_1) { Fabricate(:post, post_number: 1, topic: topic_2) }fab!(:post_2_2) { Fabricate(:post, post_number: 2, topic: topic_2) }@@ -140,7 +140,7 @@ RSpec.describe DiscourseAi::Embeddings::Vector doendcontext "with open_ai as the provider" do- fab!(:vdef) { Fabricate(:open_ai_embedding_def) }+ fab!(:vdef, :open_ai_embedding_def)def stub_vector_mapping(text, expected_embedding, result_status: 200)EmbeddingsGenerationStubs.openai_service(@@ -175,7 +175,7 @@ RSpec.describe DiscourseAi::Embeddings::Vector doendcontext "with hugging_face as the provider" do- fab!(:vdef) { Fabricate(:embedding_definition) }+ fab!(:vdef, :embedding_definition)def stub_vector_mapping(text, expected_embedding, result_status: 200)EmbeddingsGenerationStubs.hugging_face_service(@@ -189,7 +189,7 @@ RSpec.describe DiscourseAi::Embeddings::Vector doendcontext "with google as the provider" do- fab!(:vdef) { Fabricate(:gemini_embedding_def) }+ fab!(:vdef, :gemini_embedding_def)def stub_vector_mapping(text, expected_embedding, result_status: 200)EmbeddingsGenerationStubs.gemini_service(@@ -204,7 +204,7 @@ RSpec.describe DiscourseAi::Embeddings::Vector doendcontext "with cloudflare as the provider" do- fab!(:vdef) { Fabricate(:cloudflare_embedding_def) }+ fab!(:vdef, :cloudflare_embedding_def)def stub_vector_mapping(text, expected_embedding, result_status: 200)EmbeddingsGenerationStubs.cloudflare_service(diff --git a/plugins/discourse-ai/spec/lib/modules/sentiment/entry_point_spec.rb b/plugins/discourse-ai/spec/lib/modules/sentiment/entry_point_spec.rbindex 0ca1d7a3188..628e353911b 100644--- a/plugins/discourse-ai/spec/lib/modules/sentiment/entry_point_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/sentiment/entry_point_spec.rb@@ -38,10 +38,10 @@ RSpec.describe DiscourseAi::Sentiment::EntryPoint do"[{\"model_name\":\"SamLowe/roberta-base-go_emotions\",\"endpoint\":\"http://samlowe-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"j-hartmann/emotion-english-distilroberta-base\",\"endpoint\":\"http://jhartmann-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"cardiffnlp/twitter-roberta-base-sentiment-latest\",\"endpoint\":\"http://cardiffnlp-sentiment.com\",\"api_key\":\"123\"}]"end- fab!(:pm) { Fabricate(:private_message_post) }+ fab!(:pm, :private_message_post)- fab!(:post_1) { Fabricate(:post) }- fab!(:post_2) { Fabricate(:post) }+ fab!(:post_1, :post)+ fab!(:post_2, :post)describe "overall_sentiment report" dolet(:positive_classification) { { negative: 0.2, neutral: 0.3, positive: 0.7 } }@@ -68,7 +68,7 @@ RSpec.describe DiscourseAi::Sentiment::EntryPoint doexporter = Jobs::ExportCsvFile.newexporter.entity = "report"- exporter.extra = HashWithIndifferentAccess.new(name: "overall_sentiment")+ exporter.extra = ActiveSupport::HashWithIndifferentAccess.new(name: "overall_sentiment")exported_csv = []exporter.report_export { |entry| exported_csv << entry }expect(exported_csv[0]).to eq(["Day", "Overall sentiment (Positive - Negative)"])diff --git a/plugins/discourse-ai/spec/lib/personas/artifact_update_strategies/diff_spec.rb b/plugins/discourse-ai/spec/lib/personas/artifact_update_strategies/diff_spec.rbindex 5f48f5bbf1b..49a4a197158 100644--- a/plugins/discourse-ai/spec/lib/personas/artifact_update_strategies/diff_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/artifact_update_strategies/diff_spec.rb@@ -3,7 +3,7 @@RSpec.describe DiscourseAi::Personas::ArtifactUpdateStrategies::Diff dofab!(:user)fab!(:post)- fab!(:artifact) { Fabricate(:ai_artifact) }+ fab!(:artifact, :ai_artifact)fab!(:llm_model)let(:llm) { llm_model.to_llm }diff --git a/plugins/discourse-ai/spec/lib/personas/persona_spec.rb b/plugins/discourse-ai/spec/lib/personas/persona_spec.rbindex 82c55ebefc5..cde7d787e38 100644--- a/plugins/discourse-ai/spec/lib/personas/persona_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/persona_spec.rb@@ -279,7 +279,7 @@ RSpec.describe DiscourseAi::Personas::Persona doenddescribe "#craft_prompt" do- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)before doGroup.refresh_automatic_groups!@@ -308,7 +308,7 @@ RSpec.describe DiscourseAi::Personas::Persona docontext "when RAG is running with a question consolidator" dolet(:consolidated_question) { "what is the time in france?" }- fab!(:llm_model) { Fabricate(:fake_model) }+ fab!(:llm_model, :fake_model)fab!(:custom_ai_persona) doFabricate(diff --git a/plugins/discourse-ai/spec/lib/personas/tools/researcher_spec.rb b/plugins/discourse-ai/spec/lib/personas/tools/researcher_spec.rbindex 7591eaa0c50..c57c6dc01db 100644--- a/plugins/discourse-ai/spec/lib/personas/tools/researcher_spec.rb+++ b/plugins/discourse-ai/spec/lib/personas/tools/researcher_spec.rb@@ -17,7 +17,7 @@ RSpec.describe DiscourseAi::Personas::Tools::Researcher dofab!(:topic_with_tags) { Fabricate(:topic, category: category, tags: [tag_research, tag_data]) }fab!(:post) { Fabricate(:post, topic: topic_with_tags) }- fab!(:another_post) { Fabricate(:post) }+ fab!(:another_post, :post)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/lib/translation/topic_candidates_spec.rb b/plugins/discourse-ai/spec/lib/translation/topic_candidates_spec.rbindex a0ecce1df51..9e5f0673dd4 100644--- a/plugins/discourse-ai/spec/lib/translation/topic_candidates_spec.rb+++ b/plugins/discourse-ai/spec/lib/translation/topic_candidates_spec.rb@@ -25,7 +25,7 @@ describe DiscourseAi::Translation::TopicCandidates doenddescribe "SiteSetting.ai_translation_backfill_limit_to_public_content" do- fab!(:pm) { Fabricate(:private_message_topic) }+ fab!(:pm, :private_message_topic)fab!(:group_pm) { Fabricate(:private_message_topic, allowed_groups: [Fabricate(:group)]) }fab!(:public_topic) doFabricate(:topic, category: Fabricate(:category, read_restricted: false))diff --git a/plugins/discourse-ai/spec/lib/utils/research/filter_spec.rb b/plugins/discourse-ai/spec/lib/utils/research/filter_spec.rbindex dd239cf6dbd..1acaea8db07 100644--- a/plugins/discourse-ai/spec/lib/utils/research/filter_spec.rb+++ b/plugins/discourse-ai/spec/lib/utils/research/filter_spec.rb@@ -10,7 +10,7 @@ describe DiscourseAi::Utils::Research::Filter doendfab!(:user)- fab!(:user2) { Fabricate(:user) }+ fab!(:user2, :user)fab!(:feature_tag) { Fabricate(:tag, name: "feature") }fab!(:bug_tag) { Fabricate(:tag, name: "bug") }@@ -89,7 +89,7 @@ describe DiscourseAi::Utils::Research::Filter doenddescribe "security filtering" do- fab!(:secure_group) { Fabricate(:group) }+ fab!(:secure_group, :group)fab!(:secure_category) { Fabricate(:category, name: "Secure") }fab!(:secure_topic) dodiff --git a/plugins/discourse-ai/spec/models/ai_tool_spec.rb b/plugins/discourse-ai/spec/models/ai_tool_spec.rbindex 9c970970ef3..92421011d11 100644--- a/plugins/discourse-ai/spec/models/ai_tool_spec.rb+++ b/plugins/discourse-ai/spec/models/ai_tool_spec.rb@@ -483,7 +483,7 @@ RSpec.describe AiTool doSiteSetting.chat_enabled = trueend- fab!(:chat_user) { Fabricate(:user) }+ fab!(:chat_user, :user)fab!(:chat_channel) doFabricate(:chat_channel).tap do |channel|Fabricate(@@ -948,7 +948,7 @@ RSpec.describe AiTool docontext "when creating topics" dofab!(:category)- fab!(:user) { Fabricate(:admin) }+ fab!(:user, :admin)it "can create a topic" doscript = <<~JSdiff --git a/plugins/discourse-ai/spec/models/embedding_definition_spec.rb b/plugins/discourse-ai/spec/models/embedding_definition_spec.rbindex c9009f70a1d..ceec53eb75e 100644--- a/plugins/discourse-ai/spec/models/embedding_definition_spec.rb+++ b/plugins/discourse-ai/spec/models/embedding_definition_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: truedescribe EmbeddingDefinition do- fab!(:embedding_definition) { Fabricate(:open_ai_embedding_def) }- fab!(:gemini_embedding_definition) { Fabricate(:gemini_embedding_def) }+ fab!(:embedding_definition, :open_ai_embedding_def)+ fab!(:gemini_embedding_definition, :gemini_embedding_def)describe "#prepare_query_text" dolet(:text) { "test query" }diff --git a/plugins/discourse-ai/spec/models/llm_model_spec.rb b/plugins/discourse-ai/spec/models/llm_model_spec.rbindex 9395bc50f3e..67058be1399 100644--- a/plugins/discourse-ai/spec/models/llm_model_spec.rb+++ b/plugins/discourse-ai/spec/models/llm_model_spec.rb@@ -4,7 +4,7 @@ RSpec.describe LlmModel dobefore { enable_current_plugin }describe "api_key" do- fab!(:llm_model) { Fabricate(:seeded_model) }+ fab!(:llm_model, :seeded_model)before { ENV["DISCOURSE_AI_SEEDED_LLM_API_KEY_2"] = "blabla" }diff --git a/plugins/discourse-ai/spec/models/rag_document_fragment_spec.rb b/plugins/discourse-ai/spec/models/rag_document_fragment_spec.rbindex 52305e78262..1797f124b34 100644--- a/plugins/discourse-ai/spec/models/rag_document_fragment_spec.rb+++ b/plugins/discourse-ai/spec/models/rag_document_fragment_spec.rb@@ -1,10 +1,10 @@# frozen_string_literal: trueRSpec.describe RagDocumentFragment do- fab!(:persona) { Fabricate(:ai_persona) }- fab!(:upload_1) { Fabricate(:upload) }- fab!(:upload_2) { Fabricate(:upload) }- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:persona, :ai_persona)+ fab!(:upload_1, :upload)+ fab!(:upload_2, :upload)+ fab!(:vector_def, :embedding_definition)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/models/reviewable_ai_post_spec.rb b/plugins/discourse-ai/spec/models/reviewable_ai_post_spec.rbindex 5d13449dabe..7e914fc1e30 100644--- a/plugins/discourse-ai/spec/models/reviewable_ai_post_spec.rb+++ b/plugins/discourse-ai/spec/models/reviewable_ai_post_spec.rb@@ -3,7 +3,7 @@describe ReviewableAiPost dosubject(:reviewable_ai_post) { described_class.new }- fab!(:target) { Fabricate(:post) }+ fab!(:target, :post)before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/requests/admin/ai_artifacts_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_artifacts_controller_spec.rbindex 83896f05d17..c2630352aab 100644--- a/plugins/discourse-ai/spec/requests/admin/ai_artifacts_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/ai_artifacts_controller_spec.rb@@ -3,7 +3,7 @@RSpec.describe DiscourseAi::Admin::AiArtifactsController, type: :request dofab!(:admin)fab!(:user)- fab!(:target_post) { Fabricate(:post) }+ fab!(:target_post, :post)before doenable_current_plugin@@ -36,7 +36,7 @@ RSpec.describe DiscourseAi::Admin::AiArtifactsController, type: :request doenddescribe "GET #show" do- fab!(:artifact) { Fabricate(:ai_artifact) }+ fab!(:artifact, :ai_artifact)it "returns a single artifact" doget "/admin/plugins/discourse-ai/ai-artifacts/#{artifact.id}.json"@@ -78,7 +78,7 @@ RSpec.describe DiscourseAi::Admin::AiArtifactsController, type: :request doenddescribe "PUT #update" do- fab!(:artifact) { Fabricate(:ai_artifact) }+ fab!(:artifact, :ai_artifact)it "updates fields" doput "/admin/plugins/discourse-ai/ai-artifacts/#{artifact.id}.json",@@ -95,7 +95,7 @@ RSpec.describe DiscourseAi::Admin::AiArtifactsController, type: :request doenddescribe "DELETE #destroy" do- fab!(:artifact) { Fabricate(:ai_artifact) }+ fab!(:artifact, :ai_artifact)it "removes the artifact" doexpect { delete "/admin/plugins/discourse-ai/ai-artifacts/#{artifact.id}.json" }.to change(diff --git a/plugins/discourse-ai/spec/requests/admin/ai_features_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_features_controller_spec.rbindex 3326df4f770..4de5c1511a1 100644--- a/plugins/discourse-ai/spec/requests/admin/ai_features_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/ai_features_controller_spec.rb@@ -5,8 +5,8 @@ RSpec.describe DiscourseAi::Admin::AiFeaturesController dofab!(:admin)fab!(:group)fab!(:llm_model)- fab!(:summarizer_persona) { Fabricate(:ai_persona) }- fab!(:alternate_summarizer_persona) { Fabricate(:ai_persona) }+ fab!(:summarizer_persona, :ai_persona)+ fab!(:alternate_summarizer_persona, :ai_persona)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/requests/admin/ai_llms_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_llms_controller_spec.rbindex 1fb2c526098..82bb861ce00 100644--- a/plugins/discourse-ai/spec/requests/admin/ai_llms_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/ai_llms_controller_spec.rb@@ -11,7 +11,7 @@ RSpec.describe DiscourseAi::Admin::AiLlmsController dodescribe "GET #index" dofab!(:llm_model) { Fabricate(:llm_model, enabled_chat_bot: true) }- fab!(:llm_model2) { Fabricate(:llm_model) }+ fab!(:llm_model2, :llm_model)fab!(:ai_persona) doFabricate(:ai_persona,diff --git a/plugins/discourse-ai/spec/requests/admin/ai_spam_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_spam_controller_spec.rbindex 246b35f15eb..2d84082d346 100644--- a/plugins/discourse-ai/spec/requests/admin/ai_spam_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/ai_spam_controller_spec.rb@@ -219,7 +219,7 @@ RSpec.describe DiscourseAi::Admin::AiSpamController doenddescribe "#test" do- fab!(:spam_post) { Fabricate(:post) }+ fab!(:spam_post, :post)fab!(:spam_post2) { Fabricate(:post, topic: spam_post.topic, raw: "something special 123") }fab!(:setting) doAiModerationSetting.create(diff --git a/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rbindex 190f3488f5c..f911b36e947 100644--- a/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/rag_document_fragments_controller_spec.rb@@ -4,7 +4,7 @@ RSpec.describe DiscourseAi::Admin::RagDocumentFragmentsController dofab!(:admin)fab!(:ai_persona)- fab!(:vector_def) { Fabricate(:embedding_definition) }+ fab!(:vector_def, :embedding_definition)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/requests/admin/reviewable_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/reviewable_controller_spec.rbindex eee480db37a..d6385f50ea0 100644--- a/plugins/discourse-ai/spec/requests/admin/reviewable_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/reviewable_controller_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueRSpec.describe ReviewablesController do- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)fab!(:admin)fab!(:llm_model)diff --git a/plugins/discourse-ai/spec/requests/ai_bot/artifact_key_values_controller_spec.rb b/plugins/discourse-ai/spec/requests/ai_bot/artifact_key_values_controller_spec.rbindex e55bf913f13..8e137384863 100644--- a/plugins/discourse-ai/spec/requests/ai_bot/artifact_key_values_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/ai_bot/artifact_key_values_controller_spec.rb@@ -3,7 +3,7 @@RSpec.describe DiscourseAi::AiBot::ArtifactKeyValuesController dofab!(:user)fab!(:admin)- fab!(:other_user) { Fabricate(:user) }+ fab!(:other_user, :user)fab!(:private_message_topic) { Fabricate(:private_message_topic, user: user) }fab!(:private_message_post) { Fabricate(:post, topic: private_message_topic, user: user) }fab!(:artifact) dodiff --git a/plugins/discourse-ai/spec/requests/ai_bot/bot_controller_spec.rb b/plugins/discourse-ai/spec/requests/ai_bot/bot_controller_spec.rbindex 4616fd53c07..47d3d45aaa0 100644--- a/plugins/discourse-ai/spec/requests/ai_bot/bot_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/ai_bot/bot_controller_spec.rb@@ -2,7 +2,7 @@RSpec.describe DiscourseAi::AiBot::BotController dofab!(:user)- fab!(:pm_topic) { Fabricate(:private_message_topic) }+ fab!(:pm_topic, :private_message_topic)fab!(:pm_post) { Fabricate(:post, topic: pm_topic) }fab!(:pm_post2) { Fabricate(:post, topic: pm_topic) }fab!(:pm_post3) { Fabricate(:post, topic: pm_topic) }diff --git a/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rb b/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rbindex 678a23658f8..953a2bcbd86 100644--- a/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/ai_bot/shared_ai_conversations_controller_spec.rb@@ -13,7 +13,7 @@ RSpec.describe DiscourseAi::AiBot::SharedAiConversationsController dofab!(:user) { Fabricate(:user, refresh_auto_groups: true) }fab!(:topic)- fab!(:pm) { Fabricate(:private_message_topic) }+ fab!(:pm, :private_message_topic)fab!(:user_pm) { Fabricate(:private_message_topic, recipient: user) }fab!(:bot_user) dodiff --git a/plugins/discourse-ai/spec/requests/ai_bot/topic_serialization_spec.rb b/plugins/discourse-ai/spec/requests/ai_bot/topic_serialization_spec.rbindex 8d111e5f9df..1da3fa29c6a 100644--- a/plugins/discourse-ai/spec/requests/ai_bot/topic_serialization_spec.rb+++ b/plugins/discourse-ai/spec/requests/ai_bot/topic_serialization_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueRSpec.describe "AI Bot Post Serializer" do- fab!(:current_user) { Fabricate(:user) }- fab!(:bot_user) { Fabricate(:user) }+ fab!(:current_user, :user)+ fab!(:bot_user, :user)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb b/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rbindex c256bfa6916..510dc10c0fc 100644--- a/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/embeddings/embeddings_controller_spec.rb@@ -2,7 +2,7 @@describe DiscourseAi::Embeddings::EmbeddingsController docontext "when performing a topic search" do- fab!(:vector_def) { Fabricate(:open_ai_embedding_def) }+ fab!(:vector_def, :open_ai_embedding_def)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/requests/summarization/chat_summary_controller_spec.rb b/plugins/discourse-ai/spec/requests/summarization/chat_summary_controller_spec.rbindex 607013f5725..826711bdc4c 100644--- a/plugins/discourse-ai/spec/requests/summarization/chat_summary_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/summarization/chat_summary_controller_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe DiscourseAi::Summarization::ChatSummaryController do- fab!(:current_user) { Fabricate(:user) }+ fab!(:current_user, :user)fab!(:group)before do@@ -20,7 +20,7 @@ RSpec.describe DiscourseAi::Summarization::ChatSummaryController dodescribe "#show" docontext "when the user is not allowed to join the channel" do- fab!(:channel) { Fabricate(:private_category_channel) }+ fab!(:channel, :private_category_channel)it "returns a 403" doget "/discourse-ai/summarization/channels/#{channel.id}", params: { since: 6 }diff --git a/plugins/discourse-ai/spec/requests/summarization/summary_controller_spec.rb b/plugins/discourse-ai/spec/requests/summarization/summary_controller_spec.rbindex 62a079eeb20..a6f27d4648c 100644--- a/plugins/discourse-ai/spec/requests/summarization/summary_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/summarization/summary_controller_spec.rb@@ -50,7 +50,7 @@ RSpec.describe DiscourseAi::Summarization::SummaryController doendcontext "when the user is a member of an allowlisted group" do- fab!(:user) { Fabricate(:leader) }+ fab!(:user, :leader)before dosign_in(user)@@ -140,7 +140,7 @@ RSpec.describe DiscourseAi::Summarization::SummaryController dofab!(:post_1) { Fabricate(:post, topic: topic, post_number: 1) }fab!(:post_2) { Fabricate(:post, topic: topic, post_number: 2) }- fab!(:topic_1) { Fabricate(:topic) }+ fab!(:topic_1, :topic)fab!(:post_3) { Fabricate(:post, topic: topic_1, post_number: 1) }fab!(:post_4) { Fabricate(:post, topic: topic_1, post_number: 2) }diff --git a/plugins/discourse-ai/spec/requests/topic_spec.rb b/plugins/discourse-ai/spec/requests/topic_spec.rbindex 85acb3ba8bd..25672f01f92 100644--- a/plugins/discourse-ai/spec/requests/topic_spec.rb+++ b/plugins/discourse-ai/spec/requests/topic_spec.rb@@ -2,10 +2,10 @@describe ::TopicsController dofab!(:topic)- fab!(:topic1) { Fabricate(:topic) }- fab!(:topic2) { Fabricate(:topic) }- fab!(:topic3) { Fabricate(:topic) }- fab!(:user) { Fabricate(:admin) }+ fab!(:topic1, :topic)+ fab!(:topic2, :topic)+ fab!(:topic3, :topic)+ fab!(:user, :admin)before doenable_current_plugindiff --git a/plugins/discourse-ai/spec/requests/translation/translation_controller_spec.rb b/plugins/discourse-ai/spec/requests/translation/translation_controller_spec.rbindex 656b68a5e85..870ea370321 100644--- a/plugins/discourse-ai/spec/requests/translation/translation_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/translation/translation_controller_spec.rb@@ -3,7 +3,7 @@describe DiscourseAi::Translation::TranslationController dofab!(:user)fab!(:admin)- fab!(:test_post) { Fabricate(:post) }+ fab!(:test_post, :post)fab!(:group)before dodiff --git a/plugins/discourse-ai/spec/serializers/ai_chat_channel_serializer_spec.rb b/plugins/discourse-ai/spec/serializers/ai_chat_channel_serializer_spec.rbindex a7f010fd103..5751bafde93 100644--- a/plugins/discourse-ai/spec/serializers/ai_chat_channel_serializer_spec.rb+++ b/plugins/discourse-ai/spec/serializers/ai_chat_channel_serializer_spec.rb@@ -7,7 +7,7 @@ RSpec.describe AiChatChannelSerializer dodescribe "#title" docontext "when the channel is a DM" do- fab!(:dm_channel) { Fabricate(:direct_message_channel) }+ fab!(:dm_channel, :direct_message_channel)it "display every participant" doserialized = described_class.new(dm_channel, scope: Guardian.new(admin), root: nil)@@ -17,7 +17,7 @@ RSpec.describe AiChatChannelSerializer doendcontext "when the channel is a regular one" do- fab!(:channel) { Fabricate(:chat_channel) }+ fab!(:channel, :chat_channel)it "displays the category title" doserialized = described_class.new(channel, scope: Guardian.new(admin), root: nil)diff --git a/plugins/discourse-ai/spec/serializers/ai_features_persona_serializer_spec.rb b/plugins/discourse-ai/spec/serializers/ai_features_persona_serializer_spec.rbindex ea1438bee45..d9a5ac7f1d7 100644--- a/plugins/discourse-ai/spec/serializers/ai_features_persona_serializer_spec.rb+++ b/plugins/discourse-ai/spec/serializers/ai_features_persona_serializer_spec.rb@@ -4,7 +4,7 @@ RSpec.describe AiFeaturesPersonaSerializer dofab!(:admin)fab!(:ai_persona)fab!(:group)- fab!(:group_2) { Fabricate(:group) }+ fab!(:group_2, :group)before { enable_current_plugin }diff --git a/plugins/discourse-ai/spec/services/discourse_ai/topic_summarization_spec.rb b/plugins/discourse-ai/spec/services/discourse_ai/topic_summarization_spec.rbindex d0ee7712b77..74dc3341eb2 100644--- a/plugins/discourse-ai/spec/services/discourse_ai/topic_summarization_spec.rb+++ b/plugins/discourse-ai/spec/services/discourse_ai/topic_summarization_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe DiscourseAi::TopicSummarization do- fab!(:user) { Fabricate(:admin) }+ fab!(:user, :admin)fab!(:topic) { Fabricate(:topic, highest_post_number: 2) }fab!(:post_1) { Fabricate(:post, topic: topic, post_number: 1) }fab!(:post_2) { Fabricate(:post, topic: topic, post_number: 2) }diff --git a/plugins/discourse-ai/spec/system/admin_ai_features_spec.rb b/plugins/discourse-ai/spec/system/admin_ai_features_spec.rbindex e4e5458e917..923175bf05b 100644--- a/plugins/discourse-ai/spec/system/admin_ai_features_spec.rb+++ b/plugins/discourse-ai/spec/system/admin_ai_features_spec.rb@@ -3,9 +3,9 @@RSpec.describe "Admin AI features configuration", type: :system dofab!(:admin)fab!(:llm_model)- fab!(:summarization_persona) { Fabricate(:ai_persona) }- fab!(:group_1) { Fabricate(:group) }- fab!(:group_2) { Fabricate(:group) }+ fab!(:summarization_persona, :ai_persona)+ fab!(:group_1, :group)+ fab!(:group_2, :group)let(:page_header) { PageObjects::Components::DPageHeader.new }let(:form) { PageObjects::Components::FormKit.new("form") }let(:ai_features_page) { PageObjects::Pages::AdminAiFeatures.new }diff --git a/plugins/discourse-ai/spec/system/ai_bot/artifact_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/artifact_spec.rbindex 24282ddf38d..5a0998c2b32 100644--- a/plugins/discourse-ai/spec/system/ai_bot/artifact_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/artifact_spec.rb@@ -3,7 +3,7 @@RSpec.describe "AI Artifact with Data Attributes", type: :system dofab!(:admin)fab!(:user)- fab!(:author) { Fabricate(:user) }+ fab!(:author, :user)fab!(:category) { Fabricate(:category, user: admin, read_restricted: false) }fab!(:topic) { Fabricate(:topic, category: category, user: author) }fab!(:post) { Fabricate(:post, topic: topic, user: author) }diff --git a/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rbindex 2cf6e778844..9ea7586ccd6 100644--- a/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/header_toggle_spec.rb@@ -7,7 +7,7 @@ RSpec.describe "AI Bot - Header Toggle", type: :system dofab!(:user) { Fabricate(:user, refresh_auto_groups: true) }fab!(:group)- fab!(:regular_topic) { Fabricate(:topic) }+ fab!(:regular_topic, :topic)fab!(:gpt_4) { Fabricate(:llm_model, name: "gpt-4") }fab!(:gpt_3_5_turbo) { Fabricate(:llm_model, name: "gpt-3.5-turbo") }diff --git a/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rbindex d284c57e394..dbb7157a060 100644--- a/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/homepage_spec.rb@@ -294,7 +294,7 @@ RSpec.describe "AI Bot - Homepage", type: :system doendit "displays last_7_days label in the sidebar" do- pm.update!(last_posted_at: Time.zone.now - 5.days)+ pm.update!(last_posted_at: 5.days.ago)visit "/"header.click_bot_button@@ -303,7 +303,7 @@ RSpec.describe "AI Bot - Homepage", type: :system doendit "displays last_30_days label in the sidebar" do- pm.update!(last_posted_at: Time.zone.now - 28.days)+ pm.update!(last_posted_at: 28.days.ago)visit "/"header.click_bot_buttondiff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rbindex 786944165eb..f70c2498eb6 100644--- a/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_composer_helper_spec.rb@@ -2,7 +2,7 @@RSpec.describe "AI Composer helper", type: :system dofab!(:user) { Fabricate(:admin, refresh_auto_groups: true) }- fab!(:non_member_group) { Fabricate(:group) }+ fab!(:non_member_group, :group)fab!(:embedding_definition)fab!(:custom_prompts_persona) do@@ -28,12 +28,12 @@ RSpec.describe "AI Composer helper", type: :system dolet(:topic_page) { PageObjects::Pages::Topic.new }fab!(:category)- fab!(:category_2) { Fabricate(:category) }- fab!(:video) { Fabricate(:tag) }- fab!(:music) { Fabricate(:tag) }- fab!(:cloud) { Fabricate(:tag) }- fab!(:feedback) { Fabricate(:tag) }- fab!(:review) { Fabricate(:tag) }+ fab!(:category_2, :category)+ fab!(:video, :tag)+ fab!(:music, :tag)+ fab!(:cloud, :tag)+ fab!(:feedback, :tag)+ fab!(:review, :tag)fab!(:topic) { Fabricate(:topic, category: category, tags: [video, music]) }fab!(:post) doFabricate(diff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_image_caption_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_image_caption_spec.rbindex 4d23bf65a4b..878ed34198d 100644--- a/plugins/discourse-ai/spec/system/ai_helper/ai_image_caption_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_image_caption_spec.rb@@ -2,7 +2,7 @@RSpec.describe "AI image caption", type: :system dofab!(:user) { Fabricate(:admin, refresh_auto_groups: true) }- fab!(:non_member_group) { Fabricate(:group) }+ fab!(:non_member_group, :group)let(:user_preferences_ai_page) { PageObjects::Pages::UserPreferencesAi.new }let(:topic_page) { PageObjects::Pages::Topic.new }fab!(:topic)diff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rbindex 1cbb930bd0c..c2e93b7dc89 100644--- a/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_post_helper_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueRSpec.describe "AI Post helper", type: :system do- fab!(:user) { Fabricate(:admin) }- fab!(:non_member_group) { Fabricate(:group) }+ fab!(:user, :admin)+ fab!(:non_member_group, :group)fab!(:topic)fab!(:post) doFabricate(diff --git a/plugins/discourse-ai/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb b/plugins/discourse-ai/spec/system/ai_helper/ai_split_topic_suggestion_spec.rbindex a993f004bb2..7141b583895 100644--- a/plugins/discourse-ai/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_helper/ai_split_topic_suggestion_spec.rb@@ -1,11 +1,11 @@# frozen_string_literal: trueRSpec.describe "AI Post helper", type: :system do- fab!(:user) { Fabricate(:admin) }- fab!(:non_member_group) { Fabricate(:group) }+ fab!(:user, :admin)+ fab!(:non_member_group, :group)fab!(:topic)fab!(:category)- fab!(:category_2) { Fabricate(:category) }+ fab!(:category_2, :category)fab!(:post) doFabricate(:post,@@ -30,11 +30,11 @@ RSpec.describe "AI Post helper", type: :system doendlet(:topic_page) { PageObjects::Pages::Topic.new }let(:suggestion_menu) { PageObjects::Components::AiSplitTopicSuggester.new }- fab!(:video) { Fabricate(:tag) }- fab!(:music) { Fabricate(:tag) }- fab!(:cloud) { Fabricate(:tag) }- fab!(:feedback) { Fabricate(:tag) }- fab!(:review) { Fabricate(:tag) }+ fab!(:video, :tag)+ fab!(:music, :tag)+ fab!(:cloud, :tag)+ fab!(:feedback, :tag)+ fab!(:review, :tag)fab!(:embedding_definition)before dodiff --git a/plugins/discourse-ai/spec/system/embeddings/semantic_search_spec.rb b/plugins/discourse-ai/spec/system/embeddings/semantic_search_spec.rbindex 1da00957eb0..ed340b89cd1 100644--- a/plugins/discourse-ai/spec/system/embeddings/semantic_search_spec.rb+++ b/plugins/discourse-ai/spec/system/embeddings/semantic_search_spec.rb@@ -5,7 +5,7 @@ RSpec.describe "AI Composer helper", type: :system dolet(:query) { "apple_pie" }let(:hypothetical_post) { "This is an hypothetical post generated from the keyword apple_pie" }- fab!(:user) { Fabricate(:admin) }+ fab!(:user, :admin)fab!(:topic)fab!(:post) { Fabricate(:post, topic: topic, raw: "Apple pie is a delicious dessert to eat") }diff --git a/plugins/discourse-ai/spec/system/llms/ai_llm_spec.rb b/plugins/discourse-ai/spec/system/llms/ai_llm_spec.rbindex 8614be50baa..314a44769dd 100644--- a/plugins/discourse-ai/spec/system/llms/ai_llm_spec.rb+++ b/plugins/discourse-ai/spec/system/llms/ai_llm_spec.rb@@ -130,7 +130,7 @@ RSpec.describe "Managing LLM configurations", type: :system docontext "with quotas" dofab!(:llm_model_1) { Fabricate(:llm_model, name: "claude-2") }- fab!(:group_1) { Fabricate(:group) }+ fab!(:group_1, :group)before { Fabricate(:llm_quota, group: group_1, llm_model: llm_model_1, max_tokens: 1000) }@@ -172,7 +172,7 @@ RSpec.describe "Managing LLM configurations", type: :system doendcontext "when seeded LLM is present" do- fab!(:llm_model) { Fabricate(:seeded_model) }+ fab!(:llm_model, :seeded_model)it "shows the provider as CDCK in the UI" dovisit "/admin/plugins/discourse-ai/ai-llms"diff --git a/plugins/discourse-ai/spec/system/summarization/chat_summarization_spec.rb b/plugins/discourse-ai/spec/system/summarization/chat_summarization_spec.rbindex 1d49a3667c0..dcbd71f01fd 100644--- a/plugins/discourse-ai/spec/system/summarization/chat_summarization_spec.rb+++ b/plugins/discourse-ai/spec/system/summarization/chat_summarization_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: trueRSpec.describe "Summarize a channel since your last visit", type: :system do- fab!(:current_user) { Fabricate(:user) }+ fab!(:current_user, :user)fab!(:group)- fab!(:channel) { Fabricate(:chat_channel) }+ fab!(:channel, :chat_channel)fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel) }let(:chat) { PageObjects::Pages::Chat.new }let(:summarization_result) { "This is a summary" }diff --git a/plugins/discourse-ai/spec/system/summarization/gists_toggle_spec.rb b/plugins/discourse-ai/spec/system/summarization/gists_toggle_spec.rbindex 94e8b59cdb0..7bfda00befc 100644--- a/plugins/discourse-ai/spec/system/summarization/gists_toggle_spec.rb+++ b/plugins/discourse-ai/spec/system/summarization/gists_toggle_spec.rb@@ -3,7 +3,7 @@describe "Gists Toggle Functionality", type: :system dofab!(:admin)fab!(:group)- fab!(:topic_with_gist) { Fabricate(:topic) }+ fab!(:topic_with_gist, :topic)fab!(:topic_ai_gist) { Fabricate(:topic_ai_gist, target: topic_with_gist) }before dodiff --git a/plugins/discourse-ai/spec/system/summarization/topic_summarization_spec.rb b/plugins/discourse-ai/spec/system/summarization/topic_summarization_spec.rbindex dd6fc677eaa..12658162b96 100644--- a/plugins/discourse-ai/spec/system/summarization/topic_summarization_spec.rb+++ b/plugins/discourse-ai/spec/system/summarization/topic_summarization_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe "Summarize a topic ", type: :system do- fab!(:current_user) { Fabricate(:user) }+ fab!(:current_user, :user)fab!(:group)fab!(:topic)fab!(:post) dodiff --git a/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb b/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rbindex ddd50e49242..376cd42ab80 100644--- a/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb+++ b/plugins/discourse-assign/app/controllers/discourse_assign/assign_controller.rb@@ -71,7 +71,7 @@ module DiscourseAssignif assign[:success]render json: success_jsonelse- render json: translate_failure(assign[:reason], assign_to), status: 400+ render json: translate_failure(assign[:reason], assign_to), status: :bad_requestendenddiff --git a/plugins/discourse-assign/spec/components/search_spec.rb b/plugins/discourse-assign/spec/components/search_spec.rbindex 18e8582abcd..168ac6fc81a 100644--- a/plugins/discourse-assign/spec/components/search_spec.rb+++ b/plugins/discourse-assign/spec/components/search_spec.rb@@ -3,8 +3,8 @@require_relative "../support/assign_allowed_group"describe Search do- fab!(:user) { Fabricate(:active_user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user, :active_user)+ fab!(:user2, :user)before doSearchIndexer.enablediff --git a/plugins/discourse-assign/spec/components/topic_query_spec.rb b/plugins/discourse-assign/spec/components/topic_query_spec.rbindex 4f3e44e24ea..ff82c3c7355 100644--- a/plugins/discourse-assign/spec/components/topic_query_spec.rb+++ b/plugins/discourse-assign/spec/components/topic_query_spec.rb@@ -6,9 +6,9 @@ describe TopicQuery dobefore { SiteSetting.assign_enabled = true }fab!(:user)- fab!(:user2) { Fabricate(:user) }- fab!(:user3) { Fabricate(:user) }- fab!(:user4) { Fabricate(:user) }+ fab!(:user2, :user)+ fab!(:user3, :user)+ fab!(:user4, :user)include_context "with group that is allowed to assign"diff --git a/plugins/discourse-assign/spec/components/topics_bulk_action_spec.rb b/plugins/discourse-assign/spec/components/topics_bulk_action_spec.rbindex 3e0fdfd2264..acc96d059bd 100644--- a/plugins/discourse-assign/spec/components/topics_bulk_action_spec.rb+++ b/plugins/discourse-assign/spec/components/topics_bulk_action_spec.rb@@ -4,8 +4,8 @@ require_relative "../support/assign_allowed_group"describe TopicsBulkAction dofab!(:post)- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)before { SiteSetting.assign_enabled = true }diff --git a/plugins/discourse-assign/spec/integration/assign_spec.rb b/plugins/discourse-assign/spec/integration/assign_spec.rbindex b4afa6d0827..a797baceec4 100644--- a/plugins/discourse-assign/spec/integration/assign_spec.rb+++ b/plugins/discourse-assign/spec/integration/assign_spec.rb@@ -166,7 +166,7 @@ describe "integration tests" doenddescribe "move post" do- fab!(:old_topic) { Fabricate(:topic) }+ fab!(:old_topic, :topic)fab!(:post) { Fabricate(:post, topic: old_topic) }fab!(:user)fab!(:assignment) dodiff --git a/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb b/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rbindex b3fcceda8d7..c3a9afea8ec 100644--- a/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb+++ b/plugins/discourse-assign/spec/jobs/regular/unassign_notification_spec.rb@@ -2,11 +2,11 @@RSpec.describe Jobs::UnassignNotification dodescribe "#execute" do- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)fab!(:topic)fab!(:post) { Fabricate(:post, topic: topic) }- fab!(:pm_post) { Fabricate(:private_message_post) }+ fab!(:pm_post, :private_message_post)fab!(:pm) { pm_post.topic }fab!(:assign_allowed_group) { Group.find_by(name: "staff") }@@ -58,7 +58,7 @@ RSpec.describe Jobs::UnassignNotification dodescribe "Group" dofab!(:assign_allowed_group) { Group.find_by(name: "staff") }- fab!(:user3) { Fabricate(:user) }+ fab!(:user3, :user)fab!(:group)fab!(:assignment) doFabricate(:topic_assignment, topic: topic, assigned_to: group, assigned_by_user: user1)diff --git a/plugins/discourse-assign/spec/jobs/scheduled/enqueue_reminders_spec.rb b/plugins/discourse-assign/spec/jobs/scheduled/enqueue_reminders_spec.rbindex cf2fa2bb382..b7e9e3696a1 100644--- a/plugins/discourse-assign/spec/jobs/scheduled/enqueue_reminders_spec.rb+++ b/plugins/discourse-assign/spec/jobs/scheduled/enqueue_reminders_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe Jobs::EnqueueReminders do- fab!(:assign_allowed_group) { Fabricate(:group) }+ fab!(:assign_allowed_group, :group)fab!(:user) { Fabricate(:user, groups: [assign_allowed_group]) }before do@@ -58,11 +58,11 @@ RSpec.describe Jobs::EnqueueReminders douser.custom_fields[PendingAssignsReminder::REMINDERS_FREQUENCY] = RemindAssignsFrequencySiteSettings::DAILY_MINUTES- user.custom_fields[PendingAssignsReminder::REMINDED_AT] = 1.days.ago ++ user.custom_fields[PendingAssignsReminder::REMINDED_AT] = 1.day.ago +(Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES - 1)user.save- assign_multiple_tasks_to(user, assigned_on: 2.day.ago)+ assign_multiple_tasks_to(user, assigned_on: 2.days.ago)assert_reminders_enqueued(1)end@@ -70,7 +70,7 @@ RSpec.describe Jobs::EnqueueReminders doit "does not enqueue a reminder if it's too soon" douser.upsert_custom_fields(PendingAssignsReminder::REMINDED_AT =>- 1.days.ago + Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES,+ 1.day.ago + Jobs::EnqueueReminders::REMINDER_BUFFER_MINUTES,)assign_multiple_tasks_to(user)diff --git a/plugins/discourse-assign/spec/lib/assigner_spec.rb b/plugins/discourse-assign/spec/lib/assigner_spec.rbindex 9c291f33a3f..98671dc1fd7 100644--- a/plugins/discourse-assign/spec/lib/assigner_spec.rb+++ b/plugins/discourse-assign/spec/lib/assigner_spec.rb@@ -561,8 +561,8 @@ RSpec.describe Assigner doenddescribe "assign_self_regex" do- fab!(:me) { Fabricate(:admin) }- fab!(:op) { Fabricate(:post) }+ fab!(:me, :admin)+ fab!(:op, :post)fab!(:reply) doFabricate(:post, topic: op.topic, user: me, raw: "Will fix. Added to my list ;)")end@@ -602,9 +602,9 @@ RSpec.describe Assigner doenddescribe "assign_other_regex" do- fab!(:me) { Fabricate(:admin) }- fab!(:other) { Fabricate(:admin) }- fab!(:op) { Fabricate(:post) }+ fab!(:me, :admin)+ fab!(:other, :admin)+ fab!(:op, :post)fab!(:reply) doFabricate(:post,diff --git a/plugins/discourse-assign/spec/lib/random_assign_utils_spec.rb b/plugins/discourse-assign/spec/lib/random_assign_utils_spec.rbindex d6670eb9a9e..b45cb2e21a5 100644--- a/plugins/discourse-assign/spec/lib/random_assign_utils_spec.rb+++ b/plugins/discourse-assign/spec/lib/random_assign_utils_spec.rb@@ -18,12 +18,12 @@ RSpec.describe RandomAssignUtils dodescribe ".automation_script!" dosubject(:auto_assign) { described_class.automation_script!(ctx, fields, automation) }- fab!(:post_1) { Fabricate(:post) }+ fab!(:post_1, :post)fab!(:topic_1) { post_1.topic }- fab!(:group_1) { Fabricate(:group) }- fab!(:user_1) { Fabricate(:user) }- fab!(:user_2) { Fabricate(:user) }- fab!(:user_3) { Fabricate(:user) }+ fab!(:group_1, :group)+ fab!(:user_1, :user)+ fab!(:user_2, :user)+ fab!(:user_3, :user)let(:ctx) { {} }let(:fields) { {} }diff --git a/plugins/discourse-assign/spec/lib/topic_query_spec.rb b/plugins/discourse-assign/spec/lib/topic_query_spec.rbindex 4c152285d97..d77ad3d0d07 100644--- a/plugins/discourse-assign/spec/lib/topic_query_spec.rb+++ b/plugins/discourse-assign/spec/lib/topic_query_spec.rb@@ -5,7 +5,7 @@ require "topic_view"describe TopicQuery dofab!(:user)fab!(:admin)- fab!(:other_admin) { Fabricate(:admin) }+ fab!(:other_admin, :admin)fab!(:user_pm) { Fabricate(:private_message_topic, user: user) }fab!(:admin_pm) { Fabricate(:private_message_topic, user: admin) }diff --git a/plugins/discourse-assign/spec/models/reviewable_spec.rb b/plugins/discourse-assign/spec/models/reviewable_spec.rbindex 59eed8b494c..7bf19dc6a9f 100644--- a/plugins/discourse-assign/spec/models/reviewable_spec.rb+++ b/plugins/discourse-assign/spec/models/reviewable_spec.rb@@ -3,8 +3,8 @@describe Reviewable dofab!(:user)fab!(:admin)- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)fab!(:reviewable1) { Fabricate(:reviewable_flagged_post, target: post1) }fab!(:reviewable2) { Fabricate(:reviewable_flagged_post, target: post2) }diff --git a/plugins/discourse-assign/spec/requests/assign_controller_spec.rb b/plugins/discourse-assign/spec/requests/assign_controller_spec.rbindex 6ff907d435f..85dd122b778 100644--- a/plugins/discourse-assign/spec/requests/assign_controller_spec.rb+++ b/plugins/discourse-assign/spec/requests/assign_controller_spec.rb@@ -9,8 +9,8 @@ RSpec.describe DiscourseAssign::AssignController doendfab!(:staff_group) { Group.find_by(name: "staff") }- fab!(:non_allowed_group) { Fabricate(:group) }- fab!(:allowed_group) { Fabricate(:group) }+ fab!(:non_allowed_group, :group)+ fab!(:allowed_group, :group)fab!(:admin)fab!(:allowed_user) { Fabricate(:user, username: "mads", name: "Mads", groups: [allowed_group]) }@@ -339,8 +339,8 @@ RSpec.describe DiscourseAssign::AssignController dodescribe "#assigned" dofab!(:topic1) { Fabricate(:topic, bumped_at: 1.hour.from_now) }- fab!(:topic2) { Fabricate(:topic, bumped_at: 2.hour.from_now) }- fab!(:topic3) { Fabricate(:topic, bumped_at: 3.hour.from_now) }+ fab!(:topic2) { Fabricate(:topic, bumped_at: 2.hours.from_now) }+ fab!(:topic3) { Fabricate(:topic, bumped_at: 3.hours.from_now) }fab!(:assignments) doFabricate(diff --git a/plugins/discourse-assign/spec/requests/list_controller_spec.rb b/plugins/discourse-assign/spec/requests/list_controller_spec.rbindex 98870df4286..ced922c1132 100644--- a/plugins/discourse-assign/spec/requests/list_controller_spec.rb+++ b/plugins/discourse-assign/spec/requests/list_controller_spec.rb@@ -8,8 +8,8 @@ describe ListController doSiteSetting.assign_enabled = trueend- fab!(:user) { Fabricate(:active_user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user, :active_user)+ fab!(:user2, :user)let(:admin) { Fabricate(:admin) }let(:post) { Fabricate(:post) }@@ -48,9 +48,9 @@ describe ListController dodescribe "#group_topics_assigned" doinclude_context "with group that is allowed to assign"- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }- fab!(:post3) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)+ fab!(:post3, :post)fab!(:topic) { post3.topic }fab!(:topic1) { post1.topic }fab!(:topic2) { post2.topic }@@ -110,9 +110,9 @@ describe ListController dodescribe "#sorting messages_assigned and group_topics_assigned" doinclude_context "with group that is allowed to assign"- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }- fab!(:post3) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)+ fab!(:post3, :post)fab!(:topic1) { post1.topic }fab!(:topic2) { post2.topic }fab!(:topic3) { post3.topic }@@ -131,7 +131,7 @@ describe ListController doit "group_topics_assigned returns sorted topicsList" dotopic1.bumped_at = Time.nowtopic2.bumped_at = 1.day.ago- topic3.bumped_at = 3.day.ago+ topic3.bumped_at = 3.days.agotopic1.views = 3topic2.views = 5@@ -178,7 +178,7 @@ describe ListController doit "messages_assigned returns sorted topicsList" dotopic1.bumped_at = Time.now- topic3.bumped_at = 3.day.ago+ topic3.bumped_at = 3.days.agotopic1.views = 3topic3.views = 1@@ -224,9 +224,9 @@ describe ListController dodescribe "filtering of topics as per parameter" doinclude_context "with group that is allowed to assign"- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }- fab!(:post3) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)+ fab!(:post3, :post)fab!(:topic1) { post1.topic }fab!(:topic2) { post2.topic }fab!(:topic3) { post3.topic }@@ -307,8 +307,8 @@ describe ListController dodescribe "#messages_assigned" doinclude_context "with group that is allowed to assign"- fab!(:post1) { Fabricate(:post) }- fab!(:post2) { Fabricate(:post) }+ fab!(:post1, :post)+ fab!(:post2, :post)before doadd_to_assign_allowed_group(user)@@ -360,9 +360,9 @@ describe ListController dofab!(:group) { Fabricate(:group, assignable_level: Group::ALIAS_LEVELS[:mods_and_admins]) }- fab!(:topic_1) { Fabricate(:topic) }- fab!(:topic_2) { Fabricate(:topic) }- fab!(:topic_3) { Fabricate(:topic) }+ fab!(:topic_1, :topic)+ fab!(:topic_2, :topic)+ fab!(:topic_3, :topic)fab!(:post_1) { Fabricate(:post, topic: topic_1) }fab!(:post_2) { Fabricate(:post, topic: topic_2) }diff --git a/plugins/discourse-assign/spec/serializers/group_show_serializer_spec.rb b/plugins/discourse-assign/spec/serializers/group_show_serializer_spec.rbindex 313df4d9d4a..a581a54f2dc 100644--- a/plugins/discourse-assign/spec/serializers/group_show_serializer_spec.rb+++ b/plugins/discourse-assign/spec/serializers/group_show_serializer_spec.rb@@ -6,7 +6,7 @@ RSpec.describe GroupShowSerializer dofab!(:group_user) { Fabricate(:group_user, group: group, user: user) }fab!(:topic)fab!(:post) { Fabricate(:post, topic: topic) }- fab!(:topic2) { Fabricate(:topic) }+ fab!(:topic2, :topic)fab!(:post2) { Fabricate(:post, topic: topic2) }let(:guardian) { Guardian.new(user) }let(:serializer) { described_class.new(group, scope: guardian) }diff --git a/plugins/discourse-assign/spec/serializers/suggested_topic_serializer_spec.rb b/plugins/discourse-assign/spec/serializers/suggested_topic_serializer_spec.rbindex 5509c7773e4..05f20584cfa 100644--- a/plugins/discourse-assign/spec/serializers/suggested_topic_serializer_spec.rb+++ b/plugins/discourse-assign/spec/serializers/suggested_topic_serializer_spec.rb@@ -6,7 +6,7 @@ RSpec.describe SuggestedTopicSerializer dofab!(:group_user) { Fabricate(:group_user, group: group, user: user) }fab!(:topic)fab!(:post) { Fabricate(:post, topic: topic) }- fab!(:topic2) { Fabricate(:topic) }+ fab!(:topic2, :topic)fab!(:post2) { Fabricate(:post, topic: topic2) }fab!(:guardian) { Guardian.new(user) }fab!(:serializer) { described_class.new(topic, scope: guardian) }diff --git a/plugins/discourse-assign/spec/system/assign_topic_spec.rb b/plugins/discourse-assign/spec/system/assign_topic_spec.rbindex df466c1f7e3..7a96b74fe2c 100644--- a/plugins/discourse-assign/spec/system/assign_topic_spec.rb+++ b/plugins/discourse-assign/spec/system/assign_topic_spec.rb@@ -3,8 +3,8 @@describe "Assign | Assigning topics", type: :system dolet(:topic_page) { PageObjects::Pages::Topic.new }let(:assign_modal) { PageObjects::Modals::Assign.new }- fab!(:admin1) { Fabricate(:admin) }- fab!(:admin2) { Fabricate(:admin) }+ fab!(:admin1, :admin)+ fab!(:admin2, :admin)fab!(:topic)fab!(:post) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-cakeday/spec/integration/cakeday_spec.rb b/plugins/discourse-cakeday/spec/integration/cakeday_spec.rbindex 64961670767..a9bef3c86e7 100644--- a/plugins/discourse-cakeday/spec/integration/cakeday_spec.rb+++ b/plugins/discourse-cakeday/spec/integration/cakeday_spec.rb@@ -35,11 +35,11 @@ describe "Anniversaries and Birthdays" dofreeze_time(time) docreated_at = time - 1.year- user1 = Fabricate(:user, created_at: created_at - 2.year)+ user1 = Fabricate(:user, created_at: created_at - 2.years)user2 = Fabricate(:user, created_at: created_at - 1.day)user3 = Fabricate(:user, created_at: created_at)user4 = Fabricate(:user, created_at: created_at + 1.day)- user5 = Fabricate(:user, created_at: created_at + 2.day)+ user5 = Fabricate(:user, created_at: created_at + 2.days)user6 = Fabricate(:user, created_at: created_at + 1.year)hidden_user = Fabricate(:user, created_at: created_at - 1.year)diff --git a/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb b/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rbindex 145a51af11e..323a1074843 100644--- a/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb+++ b/plugins/discourse-calendar/app/controllers/discourse_post_event/events_controller.rb@@ -79,14 +79,14 @@ module DiscoursePostEventfailed_json.merge(errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")],),- status: 422+ status: :unprocessable_entityendrescue StandardErrorrender json:failed_json.merge(errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")],),- status: 422+ status: :unprocessable_entityendendend@@ -112,7 +112,7 @@ module DiscoursePostEventfailed_json.merge(errors: [I18n.t("discourse_post_event.errors.bulk_invite.error")],),- status: 422+ status: :unprocessable_entityendenddiff --git a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb b/plugins/discourse-calendar/app/models/discourse_post_event/event.rbindex 703b5219e05..c8ac02cf805 100644--- a/plugins/discourse-calendar/app/models/discourse_post_event/event.rb+++ b/plugins/discourse-calendar/app/models/discourse_post_event/event.rb@@ -19,9 +19,9 @@ module DiscoursePostEventscope :visible, -> { where(deleted_at: nil) }scope :open, -> { where(closed: false) }+ before_save :chat_channel_syncafter_commit :destroy_topic_custom_field, on: %i[destroy]after_commit :create_or_update_event_date, on: %i[create update]- before_save :chat_channel_syncvalidate :raw_invitees_are_groupsvalidates :original_starts_at, presence: truediff --git a/plugins/discourse-calendar/db/migrate/20201111005205_move_data_to_event_dates.rb b/plugins/discourse-calendar/db/migrate/20201111005205_move_data_to_event_dates.rbindex a9fadab48ba..e61411fa8fd 100644--- a/plugins/discourse-calendar/db/migrate/20201111005205_move_data_to_event_dates.rb+++ b/plugins/discourse-calendar/db/migrate/20201111005205_move_data_to_event_dates.rb@@ -86,7 +86,7 @@ class MoveDataToEventDates < ActiveRecord::Migration[6.0]next if !extracted_eventfinished_at = (event.original_ends_at < Time.current) && event.original_ends_at- event_will_start_sent_at = event.original_starts_at - 1.hours+ event_will_start_sent_at = event.original_starts_at - 1.hourevent_started_sent_at = event.original_starts_atreminder_counter = due_reminders(event).lengthdiff --git a/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb b/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rbindex d794b15c426..b9015a54e14 100644--- a/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb+++ b/plugins/discourse-calendar/lib/discourse_post_event/rrule_generator.rb@@ -16,7 +16,7 @@ class RRuleGenerator::RRule::Rule.new(stringify(rrule), dtstart: starts_at, tzid: timezone)- .between(Time.current, Time.current + 14.months)+ .between(Time.current, 14.months.from_now).first(RRuleConfigurator.how_many_recurring_events(recurrence:, max_years:))enddiff --git a/plugins/discourse-calendar/lib/holiday_status.rb b/plugins/discourse-calendar/lib/holiday_status.rbindex c9dc6300b99..7f9da028eeb 100644--- a/plugins/discourse-calendar/lib/holiday_status.rb+++ b/plugins/discourse-calendar/lib/holiday_status.rb@@ -26,8 +26,7 @@ module DiscourseCalendarenddef self.emoji_name- emoji = SiteSetting.holiday_status_emoji- emoji.blank? ? "date" : emoji+ SiteSetting.holiday_status_emoji.presence || "date"endendenddiff --git a/plugins/discourse-calendar/spec/integration/curently_away_report_spec.rb b/plugins/discourse-calendar/spec/integration/curently_away_report_spec.rbindex a5a7aa8d370..b7e5d14282a 100644--- a/plugins/discourse-calendar/spec/integration/curently_away_report_spec.rb+++ b/plugins/discourse-calendar/spec/integration/curently_away_report_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: truedescribe "currently_away report" do- fab!(:user_1) { Fabricate(:user) }- fab!(:user_2) { Fabricate(:user) }- fab!(:group_1) { Fabricate(:group) }+ fab!(:user_1, :user)+ fab!(:user_2, :user)+ fab!(:group_1, :group)before { group_1.add(user_1) }diff --git a/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb b/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rbindex 8d2e2fe46cb..e882488d49a 100644--- a/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb+++ b/plugins/discourse-calendar/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb@@ -363,7 +363,7 @@ describe Jobs::DiscoursePostEventSendReminder dodef advance_to_next_occurrencefreeze_time(recurring_event.original_starts_at + 1.day + 1.hour)- recurring_event.event_dates.pending.update_all(finished_at: Time.current - 1.hour)+ recurring_event.event_dates.pending.update_all(finished_at: 1.hour.ago)recurring_event.set_next_dateenddiff --git a/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb b/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rbindex a240873ed06..2d3b0f1fad7 100644--- a/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb+++ b/plugins/discourse-calendar/spec/jobs/scheduled/monitor_event_dates_spec.rb@@ -3,9 +3,9 @@describe Jobs::DiscourseCalendar::MonitorEventDates dosubject(:job) { described_class.new }- fab!(:post_1) { Fabricate(:post) }- fab!(:post_2) { Fabricate(:post) }- fab!(:post_3) { Fabricate(:post) }+ fab!(:post_1, :post)+ fab!(:post_2, :post)+ fab!(:post_3, :post)fab!(:past_event) doFabricate(:event,@@ -188,7 +188,7 @@ describe Jobs::DiscourseCalendar::MonitorEventDates doendit "doesn’t list events with invalid reminders" do- freeze_time(7.days.after - 1.minutes)+ freeze_time(7.days.after - 1.minute)expect(job.due_reminders(invalid_event.event_dates.first)).to be_blankexpect(job.due_reminders(valid_event.event_dates.first).length).to eq(1)diff --git a/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb b/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rbindex db3e05e690e..a82536b6f2f 100644--- a/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb+++ b/plugins/discourse-calendar/spec/jobs/scheduled/update_holiday_usernames_spec.rb@@ -150,7 +150,7 @@ describe Jobs::DiscourseCalendar::UpdateHolidayUsernames docustom_status[:ends_at],)- freeze_time tomorrow + 2.day+ freeze_time tomorrow + 2.daysjob.execute(nil)post.user.reloaddiff --git a/plugins/discourse-calendar/spec/lib/discourse_post_event/event_finder_spec.rb b/plugins/discourse-calendar/spec/lib/discourse_post_event/event_finder_spec.rbindex 375e50a88e1..9844cf8ba1e 100644--- a/plugins/discourse-calendar/spec/lib/discourse_post_event/event_finder_spec.rb+++ b/plugins/discourse-calendar/spec/lib/discourse_post_event/event_finder_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe DiscoursePostEvent::EventFinder do- fab!(:current_user) { Fabricate(:user) }+ fab!(:current_user, :user)fab!(:user)subject(:finder) { DiscoursePostEvent::EventFinder }@@ -13,7 +13,7 @@ describe DiscoursePostEvent::EventFinder doenddescribe "by attending user" do- fab!(:attending_user) { Fabricate(:user) }+ fab!(:attending_user, :user)fab!(:public_event) { Fabricate(:event, status: DiscoursePostEvent::Event.statuses[:public]) }fab!(:private_event) { Fabricate(:event, status: DiscoursePostEvent::Event.statuses[:private]) }fab!(:another_event) { Fabricate(:event, status: DiscoursePostEvent::Event.statuses[:public]) }diff --git a/plugins/discourse-calendar/spec/models/calendar_event_spec.rb b/plugins/discourse-calendar/spec/models/calendar_event_spec.rbindex a5c2262e625..fcef2e56cc7 100644--- a/plugins/discourse-calendar/spec/models/calendar_event_spec.rb+++ b/plugins/discourse-calendar/spec/models/calendar_event_spec.rb@@ -166,8 +166,8 @@ describe CalendarEvent doCalendarEvent.create!(topic_id: topic.id,user_id: user.id,- start_date: Time.zone.now - 1.day,- end_date: Time.zone.now + 1.day,+ start_date: 1.day.ago,+ end_date: 1.day.from_now,)UserDestroyer.new(Discourse.system_user).destroy(user)diff --git a/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rb b/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rbindex bb4dad2ac5d..5e1fc76995b 100644--- a/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rb+++ b/plugins/discourse-calendar/spec/models/discourse_post_event/event_spec.rb@@ -33,7 +33,7 @@ describe DiscoursePostEvent::Event dolet(:event) doDiscoursePostEvent::Event.create!(id: first_post.id,- original_starts_at: Time.now + 1.hours,+ original_starts_at: Time.now + 1.hour,original_ends_at: Time.now + 2.hours,)end@@ -277,7 +277,7 @@ describe DiscoursePostEvent::Event dopost_event =DiscoursePostEvent::Event.create!(original_starts_at: 2.hours.ago,- original_ends_at: 1.hours.ago,+ original_ends_at: 1.hour.ago,post: first_post,)@@ -337,10 +337,7 @@ describe DiscoursePostEvent::Event docontext "when starts_at > current date" doit "is not ongoing" dopost_event =- DiscoursePostEvent::Event.create!(- original_starts_at: 1.hours.from_now,- post: first_post,- )+ DiscoursePostEvent::Event.create!(original_starts_at: 1.hour.from_now, post: first_post)expect(post_event.ongoing?).to be(false)end@@ -653,9 +650,9 @@ describe DiscoursePostEvent::Event doFabricate(:event,recurrence: "every_week",- recurrence_until: Time.current - 1.day,- original_starts_at: Time.current - 1.week,- original_ends_at: Time.current - 1.week + 2.hours,+ recurrence_until: 1.day.ago,+ original_starts_at: 1.week.ago,+ original_ends_at: 1.week.ago + 2.hours,)eventend@@ -701,8 +698,8 @@ describe DiscoursePostEvent::Event do:event,recurrence: "every_week",recurrence_until: nil,- original_starts_at: Time.current - 1.week,- original_ends_at: Time.current - 1.week + 2.hours,+ original_starts_at: 1.week.ago,+ original_ends_at: 1.week.ago + 2.hours,)end@@ -720,8 +717,8 @@ describe DiscoursePostEvent::Event doFabricate(:event,recurrence: nil,- original_starts_at: Time.current - 1.week,- original_ends_at: Time.current - 1.week + 2.hours,+ original_starts_at: 1.week.ago,+ original_ends_at: 1.week.ago + 2.hours,)enddiff --git a/plugins/discourse-calendar/spec/models/topic_query_spec.rb b/plugins/discourse-calendar/spec/models/topic_query_spec.rbindex a000df9a35c..757a63babaf 100644--- a/plugins/discourse-calendar/spec/models/topic_query_spec.rb+++ b/plugins/discourse-calendar/spec/models/topic_query_spec.rb@@ -3,7 +3,7 @@describe TopicQuery dodescribe "sorts events" dofab!(:user) { Fabricate(:user, admin: true) }- fab!(:notified_user) { Fabricate(:user) }+ fab!(:notified_user, :user)fab!(:topic_1) { Fabricate(:topic, user: user) }fab!(:topic_2) { Fabricate(:topic, user: user) }fab!(:topic_3) { Fabricate(:topic, user: user) }@@ -23,7 +23,7 @@ describe TopicQuery dofab!(:future_event_2) doDiscoursePostEvent::Event.create!(id: post_2.id,- original_starts_at: Time.now + 1.hours,+ original_starts_at: Time.now + 1.hour,original_ends_at: Time.now + 2.hours,)enddiff --git a/plugins/discourse-calendar/spec/requests/admin/admin_holidays_controller_spec.rb b/plugins/discourse-calendar/spec/requests/admin/admin_holidays_controller_spec.rbindex bea9d4978ee..98d01a3128c 100644--- a/plugins/discourse-calendar/spec/requests/admin/admin_holidays_controller_spec.rb+++ b/plugins/discourse-calendar/spec/requests/admin/admin_holidays_controller_spec.rb@@ -3,7 +3,7 @@module Admin::DiscourseCalendardescribe AdminHolidaysController dofab!(:admin) { Fabricate(:user, admin: true) }- fab!(:member) { Fabricate(:user) }+ fab!(:member, :user)before { SiteSetting.calendar_enabled = calendar_enabled }diff --git a/plugins/discourse-calendar/spec/requests/invitees_controller_spec.rb b/plugins/discourse-calendar/spec/requests/invitees_controller_spec.rbindex cfcbaa36d77..a587e82c70a 100644--- a/plugins/discourse-calendar/spec/requests/invitees_controller_spec.rb+++ b/plugins/discourse-calendar/spec/requests/invitees_controller_spec.rb@@ -303,8 +303,8 @@ module DiscoursePostEventcontext "when event has max attendees and is full" dofab!(:post_2) { create_post(user: Fabricate(:admin), category: Fabricate(:category)) }- fab!(:user_a) { Fabricate(:user) }- fab!(:user_b) { Fabricate(:user) }+ fab!(:user_a, :user)+ fab!(:user_b, :user)fab!(:post_event_full) dope = Fabricate(:event, post: post_2, max_attendees: 1)pe.create_invitees([{ user_id: user_a.id, status: Invitee.statuses[:going] }])diff --git a/plugins/discourse-calendar/spec/requests/sort_event_topics_spec.rb b/plugins/discourse-calendar/spec/requests/sort_event_topics_spec.rbindex 233cec1750b..42c041386eb 100644--- a/plugins/discourse-calendar/spec/requests/sort_event_topics_spec.rb+++ b/plugins/discourse-calendar/spec/requests/sort_event_topics_spec.rb@@ -9,7 +9,7 @@ RSpec.describe ListController doendfab!(:post_1) { Fabricate(:post, topic: topic_1) }fab!(:post_event_1) do- Fabricate(:event, name: "event1", post: post_1, original_starts_at: 1.days.from_now)+ Fabricate(:event, name: "event1", post: post_1, original_starts_at: 1.day.from_now)endfab!(:topic_2) doFabricate(:topic, title: "This is the second topic", user: user, category: category)diff --git a/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rb b/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rbindex c6a615073b0..e113fa34ff9 100644--- a/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rb+++ b/plugins/discourse-calendar/spec/serializers/discourse_post_event/event_serializer_spec.rb@@ -16,8 +16,8 @@ describe DiscoursePostEvent::EventSerializer doFabricate(:event, post: post, status: DiscoursePostEvent::Event.statuses[:private])end- fab!(:invitee_1) { Fabricate(:user) }- fab!(:invitee_2) { Fabricate(:user) }+ fab!(:invitee_1, :user)+ fab!(:invitee_2, :user)fab!(:group_1) doFabricate(:group).tap do |g|g.add(invitee_1)diff --git a/plugins/discourse-calendar/spec/system/post_event_spec.rb b/plugins/discourse-calendar/spec/system/post_event_spec.rbindex 72f60a119e6..613db800ce1 100644--- a/plugins/discourse-calendar/spec/system/post_event_spec.rb+++ b/plugins/discourse-calendar/spec/system/post_event_spec.rb@@ -2,7 +2,7 @@describe "Post event", type: :system dofab!(:admin)- fab!(:user) { Fabricate(:admin) }+ fab!(:user, :admin)fab!(:group)let(:composer) { PageObjects::Components::Composer.new }@@ -186,7 +186,7 @@ describe "Post event", type: :system do# - - element is visible, enabled and stablevisit "/new-topic"title = "My upcoming l33t event"- tomorrow = (Time.zone.now + 1.day).strftime("%Y-%m-%d")+ tomorrow = (1.day.from_now).strftime("%Y-%m-%d")composer.fill_title(title)composer.fill_content <<~MD[event start="#{tomorrow} 13:37" status="public"]@@ -294,8 +294,8 @@ describe "Post event", type: :system do)end- fab!(:invitable_user_1) { Fabricate(:user) }- fab!(:invitable_user_2) { Fabricate(:user) }+ fab!(:invitable_user_1, :user)+ fab!(:invitable_user_2, :user)it "can invite users to an event" dovisit(post.topic.url)diff --git a/plugins/discourse-chat-integration/app/controllers/chat_controller.rb b/plugins/discourse-chat-integration/app/controllers/chat_controller.rbindex ef0804f8377..e850cd564e6 100644--- a/plugins/discourse-chat-integration/app/controllers/chat_controller.rb+++ b/plugins/discourse-chat-integration/app/controllers/chat_controller.rb@@ -36,13 +36,13 @@ class DiscourseChatIntegration::ChatController < ApplicationControllerrender json: success_jsonrescue Discourse::InvalidParameters, ActiveRecord::RecordNotFound => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityrescue DiscourseChatIntegration::ProviderError => eRails.logger.error("Test provider failed #{e.info}")if e.info.key?(:error_key) && !e.info[:error_key].nil?- render json: { error_key: e.info[:error_key] }, status: 422+ render json: { error_key: e.info[:error_key] }, status: :unprocessable_entityelse- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendendend@@ -84,7 +84,7 @@ class DiscourseChatIntegration::ChatController < ApplicationControllerrender_serialized channel, DiscourseChatIntegration::ChannelSerializer, root: "channel"rescue Discourse::InvalidParameters => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendend@@ -104,7 +104,7 @@ class DiscourseChatIntegration::ChatController < ApplicationControllerrender_serialized channel, DiscourseChatIntegration::ChannelSerializer, root: "channel"rescue Discourse::InvalidParameters => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendend@@ -126,7 +126,7 @@ class DiscourseChatIntegration::ChatController < ApplicationControllerrender_serialized rule, DiscourseChatIntegration::RuleSerializer, root: "rule"rescue Discourse::InvalidParameters => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendend@@ -139,7 +139,7 @@ class DiscourseChatIntegration::ChatController < ApplicationControllerrender_serialized rule, DiscourseChatIntegration::RuleSerializer, root: "rule"rescue Discourse::InvalidParameters => e- render json: { errors: [e.message] }, status: 422+ render json: { errors: [e.message] }, status: :unprocessable_entityendenddiff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rbindex 70ece080885..386509aeecf 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb@@ -57,11 +57,7 @@ module DiscourseChatIntegration::Provider::SlackProviderendslack_username =- if SiteSetting.chat_integration_slack_username.present?- SiteSetting.chat_integration_slack_username- else- SiteSetting.title || "Discourse"- end+ SiteSetting.chat_integration_slack_username.presence || SiteSetting.title || "Discourse"message = { channel: channel, username: slack_username, icon_url: icon_url, attachments: [] }@@ -108,11 +104,7 @@ module DiscourseChatIntegration::Provider::SlackProviderendslack_username =- if SiteSetting.chat_integration_slack_username.present?- SiteSetting.chat_integration_slack_username- else- SiteSetting.title || "Discourse"- end+ SiteSetting.chat_integration_slack_username.presence || SiteSetting.title || "Discourse"message = {channel: "##{channel_name}",diff --git a/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb b/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rbindex dc0fc1fc08f..b747ef6b96d 100644--- a/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb+++ b/plugins/discourse-data-explorer/app/controllers/discourse_data_explorer/query_controller.rb@@ -184,7 +184,7 @@ module DiscourseDataExplorererr_msg = "#{err_class}: #{err_msg}"end- render json: { success: false, errors: [err_msg] }, status: 422+ render json: { success: false, errors: [err_msg] }, status: :unprocessable_entityelsecontent_disposition ="attachment; filename=#{query.slug}@#{Slug.for(Discourse.current_hostname, "discourse")}-#{Date.today}.dcqresult"diff --git a/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_pm_spec.rb b/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_pm_spec.rbindex 279a47a5bb7..29eeb749c1a 100644--- a/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_pm_spec.rb+++ b/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_pm_spec.rb@@ -4,9 +4,9 @@ describe "RecurringDataExplorerResultPM" dofab!(:admin)fab!(:user)- fab!(:another_user) { Fabricate(:user) }- fab!(:group_user) { Fabricate(:user) }- fab!(:not_allowed_user) { Fabricate(:user) }+ fab!(:another_user, :user)+ fab!(:group_user, :user)+ fab!(:not_allowed_user, :user)fab!(:group) { Fabricate(:group, users: [user, another_user]) }fab!(:another_group) { Fabricate(:group, users: [group_user]) }diff --git a/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_topic_spec.rb b/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_topic_spec.rbindex 55141a48e9e..2263f8d19f0 100644--- a/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_topic_spec.rb+++ b/plugins/discourse-data-explorer/spec/automation/recurring_data_explorer_result_topic_spec.rb@@ -4,9 +4,9 @@ describe "RecurringDataExplorerResultTopic" dofab!(:admin)fab!(:user)- fab!(:another_user) { Fabricate(:user) }- fab!(:group_user) { Fabricate(:user) }- fab!(:not_allowed_user) { Fabricate(:user) }+ fab!(:another_user, :user)+ fab!(:group_user, :user)+ fab!(:not_allowed_user, :user)fab!(:topic)fab!(:group) { Fabricate(:group, users: [user, another_user]) }diff --git a/plugins/discourse-data-explorer/spec/lib/data_explorer/query_group_bookmarkable_spec.rb b/plugins/discourse-data-explorer/spec/lib/data_explorer/query_group_bookmarkable_spec.rbindex e7edff806e7..9399fced1b9 100644--- a/plugins/discourse-data-explorer/spec/lib/data_explorer/query_group_bookmarkable_spec.rb+++ b/plugins/discourse-data-explorer/spec/lib/data_explorer/query_group_bookmarkable_spec.rb@@ -5,13 +5,13 @@ describe DiscourseDataExplorer::QueryGroupBookmarkable doRegisteredBookmarkable.new(DiscourseDataExplorer::QueryGroupBookmarkable)end- fab!(:admin_user) { Fabricate(:admin) }+ fab!(:admin_user, :admin)fab!(:user)fab!(:guardian) { Guardian.new(user) }- fab!(:group0) { Fabricate(:group) }- fab!(:group1) { Fabricate(:group) }- fab!(:group2) { Fabricate(:group) }- fab!(:group3) { Fabricate(:group) }+ fab!(:group0, :group)+ fab!(:group1, :group)+ fab!(:group2, :group)+ fab!(:group3, :group)fab!(:query1) doFabricate(:query,diff --git a/plugins/discourse-data-explorer/spec/report_generator_spec.rb b/plugins/discourse-data-explorer/spec/report_generator_spec.rbindex fcddfb100d9..2e0b5892849 100644--- a/plugins/discourse-data-explorer/spec/report_generator_spec.rb+++ b/plugins/discourse-data-explorer/spec/report_generator_spec.rb@@ -2,8 +2,8 @@describe DiscourseDataExplorer::ReportGenerator dofab!(:user)- fab!(:unauthorised_user) { Fabricate(:user) }- fab!(:unauthorised_group) { Fabricate(:group) }+ fab!(:unauthorised_user, :user)+ fab!(:unauthorised_group, :group)fab!(:group) { Fabricate(:group, users: [user]) }fab!(:query) { DiscourseDataExplorer::Query.find(-1) }diff --git a/plugins/discourse-data-explorer/spec/requests/group_spec.rb b/plugins/discourse-data-explorer/spec/requests/group_spec.rbindex bb63c92a15e..315b7fd7253 100644--- a/plugins/discourse-data-explorer/spec/requests/group_spec.rb+++ b/plugins/discourse-data-explorer/spec/requests/group_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: truedescribe "Data explorer group serializer additions" do- fab!(:group_user) { Fabricate(:user) }- fab!(:other_user) { Fabricate(:user) }+ fab!(:group_user, :user)+ fab!(:other_user, :user)fab!(:group)let!(:query) { DiscourseDataExplorer::Query.create!(name: "My query", sql: "") }diff --git a/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb b/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rbindex 6b6867e86b6..265f4754d31 100644--- a/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb+++ b/plugins/discourse-data-explorer/spec/requests/query_controller_spec.rb@@ -86,7 +86,7 @@ describe DiscourseDataExplorer::QueryController doenddescribe "#update" do- fab!(:user2) { Fabricate(:user) }+ fab!(:user2, :user)fab!(:group2) { Fabricate(:group, users: [user2]) }it "allows group to access system query" dodiff --git a/plugins/discourse-data-explorer/spec/system/bookmark_spec.rb b/plugins/discourse-data-explorer/spec/system/bookmark_spec.rbindex 34395c92d59..1b7095c2bbb 100644--- a/plugins/discourse-data-explorer/spec/system/bookmark_spec.rb+++ b/plugins/discourse-data-explorer/spec/system/bookmark_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe "Bookmarking reports attached to a group", type: :system do- fab!(:current_user) { Fabricate(:admin) }+ fab!(:current_user, :admin)fab!(:query_1) doFabricate(:query,diff --git a/plugins/discourse-data-explorer/spec/system/param_input_spec.rb b/plugins/discourse-data-explorer/spec/system/param_input_spec.rbindex 67ebff2c8dc..c12128eb22c 100644--- a/plugins/discourse-data-explorer/spec/system/param_input_spec.rb+++ b/plugins/discourse-data-explorer/spec/system/param_input_spec.rb@@ -45,7 +45,7 @@ RSpec.describe "Param input", type: :system doSELECT 1SQL- fab!(:current_user) { Fabricate(:admin) }+ fab!(:current_user, :admin)fab!(:all_params_query) doFabricate(:query,diff --git a/plugins/discourse-data-explorer/spec/system/reports_spec.rb b/plugins/discourse-data-explorer/spec/system/reports_spec.rbindex 3a6fcda9674..3b42a7da215 100644--- a/plugins/discourse-data-explorer/spec/system/reports_spec.rb+++ b/plugins/discourse-data-explorer/spec/system/reports_spec.rb@@ -2,7 +2,7 @@RSpec.describe "Reports", type: :system dofab!(:group) { Fabricate(:group, name: "group") }- fab!(:user) { Fabricate(:admin) }+ fab!(:user, :admin)fab!(:group_user) { Fabricate(:group_user, user: user, group: group) }fab!(:query_1) doFabricate(diff --git a/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb b/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rbindex f7afd831df9..d432c74c4d1 100644--- a/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb+++ b/plugins/discourse-gamification/app/controllers/discourse_gamification/gamification_leaderboard_controller.rb@@ -34,7 +34,7 @@ module DiscourseGamification.new(leaderboard).as_json.merge({ users: [], reason: e.message }),- status: 202+ status: :acceptedendendenddiff --git a/plugins/discourse-gamification/spec/jobs/delete_leaderboard_positions_spec.rb b/plugins/discourse-gamification/spec/jobs/delete_leaderboard_positions_spec.rbindex f167a45f1bc..ba8e5fb94aa 100644--- a/plugins/discourse-gamification/spec/jobs/delete_leaderboard_positions_spec.rb+++ b/plugins/discourse-gamification/spec/jobs/delete_leaderboard_positions_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe Jobs::DeleteLeaderboardPositions do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)fab!(:score) { Fabricate(:gamification_score, user_id: leaderboard.created_by_id) }let(:leaderboard_positions) { DiscourseGamification::LeaderboardCachedView.new(leaderboard) }diff --git a/plugins/discourse-gamification/spec/jobs/generate_leaderboard_positions_spec.rb b/plugins/discourse-gamification/spec/jobs/generate_leaderboard_positions_spec.rbindex 2184823ee64..9b09becc91e 100644--- a/plugins/discourse-gamification/spec/jobs/generate_leaderboard_positions_spec.rb+++ b/plugins/discourse-gamification/spec/jobs/generate_leaderboard_positions_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe Jobs::GenerateLeaderboardPositions do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)fab!(:score) { Fabricate(:gamification_score, user_id: leaderboard.created_by_id) }let(:leaderboard_positions) { DiscourseGamification::LeaderboardCachedView.new(leaderboard) }diff --git a/plugins/discourse-gamification/spec/jobs/recalculate_scores_spec.rb b/plugins/discourse-gamification/spec/jobs/recalculate_scores_spec.rbindex b38e48286ef..f4ddc90a284 100644--- a/plugins/discourse-gamification/spec/jobs/recalculate_scores_spec.rb+++ b/plugins/discourse-gamification/spec/jobs/recalculate_scores_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe Jobs::RecalculateScores do- fab!(:current_user) { Fabricate(:admin) }+ fab!(:current_user, :admin)before { RateLimiter.enable }diff --git a/plugins/discourse-gamification/spec/jobs/refresh_leaderboard_positions_spec.rb b/plugins/discourse-gamification/spec/jobs/refresh_leaderboard_positions_spec.rbindex 27e7ae5c223..af40ba95a05 100644--- a/plugins/discourse-gamification/spec/jobs/refresh_leaderboard_positions_spec.rb+++ b/plugins/discourse-gamification/spec/jobs/refresh_leaderboard_positions_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe Jobs::RefreshLeaderboardPositions do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)let(:leaderboard_positions) { DiscourseGamification::LeaderboardCachedView.new(leaderboard) }before { leaderboard_positions.create }diff --git a/plugins/discourse-gamification/spec/jobs/update_scores_for_today_spec.rb b/plugins/discourse-gamification/spec/jobs/update_scores_for_today_spec.rbindex ba7e3247f2a..640c572c968 100644--- a/plugins/discourse-gamification/spec/jobs/update_scores_for_today_spec.rb+++ b/plugins/discourse-gamification/spec/jobs/update_scores_for_today_spec.rb@@ -2,7 +2,7 @@describe Jobs::UpdateScoresForToday dofab!(:user)- fab!(:user_2) { Fabricate(:user) }+ fab!(:user_2, :user)fab!(:post) { Fabricate(:post, user: user, post_number: 2) }fab!(:gamification_score) { Fabricate(:gamification_score, user_id: user.id) }fab!(:gamification_score_2) dodiff --git a/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb b/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rbindex ff61ed1159b..fb38cf5d727 100644--- a/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb+++ b/plugins/discourse-gamification/spec/jobs/update_stale_leaderboard_positions_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe Jobs::UpdateStaleLeaderboardPositions do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)fab!(:score) { Fabricate(:gamification_score, user_id: leaderboard.created_by_id) }let(:leaderboard_positions) { DiscourseGamification::LeaderboardCachedView.new(leaderboard) }diff --git a/plugins/discourse-gamification/spec/lib/directory_integration_spec.rb b/plugins/discourse-gamification/spec/lib/directory_integration_spec.rbindex 05974cdebdb..11eb0fe774b 100644--- a/plugins/discourse-gamification/spec/lib/directory_integration_spec.rb+++ b/plugins/discourse-gamification/spec/lib/directory_integration_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: truedescribe DiscourseGamification::DirectoryIntegration do- fab!(:user_1) { Fabricate(:admin) }- fab!(:user_2) { Fabricate(:user) }- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:user_1, :admin)+ fab!(:user_2, :user)+ fab!(:leaderboard, :gamification_leaderboard)fab!(:score_1) { Fabricate(:gamification_score, user_id: user_1.id, score: 10, date: 8.days.ago) }fab!(:score_2) { Fabricate(:gamification_score, user_id: user_1.id, score: 40, date: 3.days.ago) }fab!(:score_3) { Fabricate(:gamification_score, user_id: user_2.id, score: 25, date: 5.days.ago) }diff --git a/plugins/discourse-gamification/spec/lib/leaderboard_cached_view_spec.rb b/plugins/discourse-gamification/spec/lib/leaderboard_cached_view_spec.rbindex fcad7a7f50c..23190ccca85 100644--- a/plugins/discourse-gamification/spec/lib/leaderboard_cached_view_spec.rb+++ b/plugins/discourse-gamification/spec/lib/leaderboard_cached_view_spec.rb@@ -3,7 +3,7 @@describe DiscourseGamification::LeaderboardCachedView dofab!(:admin)fab!(:user)- fab!(:other_user) { Fabricate(:user) }+ fab!(:other_user, :user)fab!(:moderator)fab!(:leaderboard) { Fabricate(:gamification_leaderboard, created_by_id: admin.id) }fab!(:gamification_score) { Fabricate(:gamification_score, user_id: user.id, date: 8.days.ago) }diff --git a/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb b/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rbindex a7b918fefac..bac1e373228 100755--- a/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb+++ b/plugins/discourse-gamification/spec/lib/scorables/shared_scorables_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.shared_examples "Scorable Type" do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)let(:current_user) { Fabricate(:user) }let(:other_user) { Fabricate(:user) }let(:third_user) { Fabricate(:user) }@@ -21,7 +21,7 @@ RSpec.shared_examples "Scorable Type" doendRSpec.shared_examples "Category Scoped Scorable Type" do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)let(:user) { Fabricate(:user) }let(:user_2) { Fabricate(:user) }let(:category_allowed) { Fabricate(:category) }@@ -53,7 +53,7 @@ RSpec.shared_examples "Category Scoped Scorable Type" doendRSpec.shared_examples "No Score Value" do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)let(:current_user) { Fabricate(:user) }let(:other_user) { Fabricate(:user) }let(:class_action_fabricator_for_pm) { nil }diff --git a/plugins/discourse-gamification/spec/lib/scorables/solutions_spec.rb b/plugins/discourse-gamification/spec/lib/scorables/solutions_spec.rbindex 367c0f35257..1f406dfe5f5 100644--- a/plugins/discourse-gamification/spec/lib/scorables/solutions_spec.rb+++ b/plugins/discourse-gamification/spec/lib/scorables/solutions_spec.rb@@ -3,8 +3,8 @@RSpec.describe DiscourseGamification::Solutions dofab!(:category)fab!(:topic) { Fabricate(:topic, category: category) }- fab!(:question_user) { Fabricate(:user) }- fab!(:answer_user) { Fabricate(:user) }+ fab!(:question_user, :user)+ fab!(:answer_user, :user)fab!(:answer_post) { Fabricate(:post, topic: topic, user: answer_user) }before { SiteSetting.solution_score_value = 5 }diff --git a/plugins/discourse-gamification/spec/models/gamification_leaderboard_spec.rb b/plugins/discourse-gamification/spec/models/gamification_leaderboard_spec.rbindex b7ea4b737dd..0c1c3367ce4 100644--- a/plugins/discourse-gamification/spec/models/gamification_leaderboard_spec.rb+++ b/plugins/discourse-gamification/spec/models/gamification_leaderboard_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe DiscourseGamification::GamificationLeaderboard, type: :model do- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)describe ".resolve_period" doit "returns default period given a blank period" dodiff --git a/plugins/discourse-gamification/spec/models/gamification_score_spec.rb b/plugins/discourse-gamification/spec/models/gamification_score_spec.rbindex 9513217eb4d..f76e96c6abd 100644--- a/plugins/discourse-gamification/spec/models/gamification_score_spec.rb+++ b/plugins/discourse-gamification/spec/models/gamification_score_spec.rb@@ -2,7 +2,7 @@RSpec.describe DiscourseGamification::GamificationScore, type: :model dofab!(:user)- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)before { DiscourseGamification::LeaderboardCachedView.create_all }diff --git a/plugins/discourse-gamification/spec/models/user_spec.rb b/plugins/discourse-gamification/spec/models/user_spec.rbindex d23611a7988..9e7af34e58f 100644--- a/plugins/discourse-gamification/spec/models/user_spec.rb+++ b/plugins/discourse-gamification/spec/models/user_spec.rb@@ -2,7 +2,7 @@describe User, type: :model dofab!(:user)- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)before doFabricate(:gamification_score, user_id: user.id, score: 10, date: 8.days.ago)diff --git a/plugins/discourse-gamification/spec/plugin_spec.rb b/plugins/discourse-gamification/spec/plugin_spec.rbindex 8cf43b7cae2..9418a4eed1a 100644--- a/plugins/discourse-gamification/spec/plugin_spec.rb+++ b/plugins/discourse-gamification/spec/plugin_spec.rb@@ -36,9 +36,9 @@ describe DiscourseGamification doendcontext "when merging users" do- fab!(:user_1) { Fabricate(:user) }- fab!(:user_2) { Fabricate(:user) }- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:user_1, :user)+ fab!(:user_2, :user)+ fab!(:leaderboard, :gamification_leaderboard)before doSiteSetting.discourse_gamification_enabled = truediff --git a/plugins/discourse-gamification/spec/requests/gamification_leaderboard_controller_spec.rb b/plugins/discourse-gamification/spec/requests/gamification_leaderboard_controller_spec.rbindex 91193cc23c6..831023dd389 100644--- a/plugins/discourse-gamification/spec/requests/gamification_leaderboard_controller_spec.rb+++ b/plugins/discourse-gamification/spec/requests/gamification_leaderboard_controller_spec.rb@@ -3,7 +3,7 @@RSpec.describe DiscourseGamification::GamificationLeaderboardController dofab!(:group)fab!(:current_user) { Fabricate(:user, group_ids: [group.id]) }- fab!(:user_2) { Fabricate(:user) }+ fab!(:user_2, :user)fab!(:staged_user) { Fabricate(:user, staged: true) }fab!(:anon_user) { Fabricate(:user, email: "[email protected]") }fab!(:currently_suspended_user) do@@ -13,7 +13,7 @@ RSpec.describe DiscourseGamification::GamificationLeaderboardController doFabricate(:user, suspended_at: Time.now, suspended_till: 5.days.ago)end- fab!(:user_3) { Fabricate(:user) }+ fab!(:user_3, :user)let!(:create_score) { UserVisit.create(user_id: current_user.id, visited_at: 2.days.ago) }let!(:create_score_for_user2) { UserVisit.create(user_id: user_2.id, visited_at: 2.days.ago) }diff --git a/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb b/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rbindex d721f03b69e..7d5561cd0a9 100644--- a/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb+++ b/plugins/discourse-gamification/spec/system/admin_leaderboards_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe "Admin leaderboards", type: :system do- fab!(:current_user) { Fabricate(:admin) }+ fab!(:current_user, :admin)let(:admin_leaderboard_page) { PageObjects::Pages::AdminLeaderboards.new }let(:dialog) { PageObjects::Components::Dialog.new }diff --git a/plugins/discourse-gamification/spec/system/recalculate_scores_form_spec.rb b/plugins/discourse-gamification/spec/system/recalculate_scores_form_spec.rbindex 7feaf00aed1..7debd3c3907 100644--- a/plugins/discourse-gamification/spec/system/recalculate_scores_form_spec.rb+++ b/plugins/discourse-gamification/spec/system/recalculate_scores_form_spec.rb@@ -4,7 +4,7 @@ describe "Recalculate Scores Form", type: :system dolet(:recalculate_scores_modal) { PageObjects::Modals::RecalculateScoresForm.new }fab!(:admin)- fab!(:leaderboard) { Fabricate(:gamification_leaderboard) }+ fab!(:leaderboard, :gamification_leaderboard)before doRateLimiter.enablediff --git a/plugins/discourse-github/spec/lib/github_badges_spec.rb b/plugins/discourse-github/spec/lib/github_badges_spec.rbindex 37205698522..c24487e90f1 100644--- a/plugins/discourse-github/spec/lib/github_badges_spec.rb+++ b/plugins/discourse-github/spec/lib/github_badges_spec.rb@@ -49,7 +49,7 @@ describe DiscourseGithubPlugin::GithubBadges dorepo2.commits.create!(sha: "4",email: bronze_user_repo_2.email,- committed_at: 2.day.ago,+ committed_at: 2.days.ago,role_id: roles[:committer],)diff --git a/plugins/discourse-math/spec/system/post_spec.rb b/plugins/discourse-math/spec/system/post_spec.rbindex 50fd96f1b70..25e8847de7c 100644--- a/plugins/discourse-math/spec/system/post_spec.rb+++ b/plugins/discourse-math/spec/system/post_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe "Discourse Math - post", type: :system do- fab!(:current_user) { Fabricate(:admin) }+ fab!(:current_user, :admin)before doSiteSetting.discourse_math_enabled = truediff --git a/plugins/discourse-microsoft-auth/spec/integration/microsoft_auth_spec.rb b/plugins/discourse-microsoft-auth/spec/integration/microsoft_auth_spec.rbindex 721bb6c7416..a99be4e3c05 100644--- a/plugins/discourse-microsoft-auth/spec/integration/microsoft_auth_spec.rb+++ b/plugins/discourse-microsoft-auth/spec/integration/microsoft_auth_spec.rb@@ -6,7 +6,7 @@ describe "Microsoft OAuth2" dolet(:client_secret) { "adddcccdddd99922" }let(:temp_code) { "microsoft_temp_code_544254" }- fab!(:user1) { Fabricate(:user) }+ fab!(:user1, :user)def setup_ms_emails_stub(email:)stub_request(:get, "https://graph.microsoft.com/v1.0/me").with(diff --git a/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb b/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rbindex ae8b25f6590..074e2b049c9 100644--- a/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb+++ b/plugins/discourse-patreon/app/controllers/patreon/patreon_admin_controller.rb@@ -38,7 +38,7 @@ class Patreon::PatreonAdminController < Admin::AdminControllerdef editif params[:rewards_ids].nil? || !is_number?(params[:group_id])- return render json: { message: "Error" }, status: 500+ return render json: { message: "Error" }, status: :internal_server_errorendfilters = PluginStore.get(Patreon::PLUGIN_NAME, "filters") || {}@@ -51,7 +51,9 @@ class Patreon::PatreonAdminController < Admin::AdminControllerenddef delete- return render json: { message: "Error" }, status: 500 unless is_number?(params[:group_id])+ unless is_number?(params[:group_id])+ return render json: { message: "Error" }, status: :internal_server_error+ endfilters = PluginStore.get(Patreon::PLUGIN_NAME, "filters")@@ -67,7 +69,7 @@ class Patreon::PatreonAdminController < Admin::AdminControllerPatreon::Patron.sync_groupsrender json: success_jsonrescue => e- render json: { message: e.message }, status: 500+ render json: { message: e.message }, status: :internal_server_errorendenddiff --git a/plugins/discourse-patreon/app/controllers/patreon/patreon_webhook_controller.rb b/plugins/discourse-patreon/app/controllers/patreon/patreon_webhook_controller.rbindex aaf6ad40628..e110e965c9b 100644--- a/plugins/discourse-patreon/app/controllers/patreon/patreon_webhook_controller.rb+++ b/plugins/discourse-patreon/app/controllers/patreon/patreon_webhook_controller.rb@@ -56,7 +56,7 @@ class Patreon::PatreonWebhookController < ApplicationControllerJobs.enqueue(:sync_patron_groups, patreon_id: patreon_id)- render body: nil, status: 200+ render body: nil, status: :okenddef eventdiff --git a/plugins/discourse-patreon/spec/integration/patreon_auth_spec.rb b/plugins/discourse-patreon/spec/integration/patreon_auth_spec.rbindex 03cf62d0163..c1b2e781c39 100644--- a/plugins/discourse-patreon/spec/integration/patreon_auth_spec.rb+++ b/plugins/discourse-patreon/spec/integration/patreon_auth_spec.rb@@ -6,8 +6,8 @@ describe "Patreon Oauth2" dolet(:client_secret) { "adddcccdddd99922" }let(:temp_code) { "patreon_temp_code_544254" }- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)def setup_patreon_emails_stub(email:, verified:)stub_request(:get, "https://api.patreon.com/oauth2/api/current_user").with(diff --git a/plugins/discourse-policy/spec/lib/check_policy_spec.rb b/plugins/discourse-policy/spec/lib/check_policy_spec.rbindex e33e7767577..b4a337585f1 100644--- a/plugins/discourse-policy/spec/lib/check_policy_spec.rb+++ b/plugins/discourse-policy/spec/lib/check_policy_spec.rb@@ -3,8 +3,8 @@describe Jobs::DiscoursePolicy::CheckPolicy dosubject(:job) { described_class.new }- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)fab!(:group) dogroup = Fabricate(:group)diff --git a/plugins/discourse-policy/spec/mailers/policy_email_spec.rb b/plugins/discourse-policy/spec/mailers/policy_email_spec.rbindex f32b7572f44..fb801ece250 100644--- a/plugins/discourse-policy/spec/mailers/policy_email_spec.rb+++ b/plugins/discourse-policy/spec/mailers/policy_email_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe Jobs::UserEmail do- fab!(:user1) { Fabricate(:user) }+ fab!(:user1, :user)fab!(:group1) dogroup = Fabricate(:group)diff --git a/plugins/discourse-policy/spec/models/post_policy_spec.rb b/plugins/discourse-policy/spec/models/post_policy_spec.rbindex 3e6cec42c83..ee4946fd4a0 100644--- a/plugins/discourse-policy/spec/models/post_policy_spec.rb+++ b/plugins/discourse-policy/spec/models/post_policy_spec.rb@@ -3,8 +3,8 @@RSpec.describe PostPolicy doinclude ActiveSupport::Testing::TimeHelpers- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)fab!(:inactive_user) { Fabricate(:user, active: false) }fab!(:suspended_user) { Fabricate(:user, suspended_till: 1.year.from_now) }diff --git a/plugins/discourse-policy/spec/plugin_spec.rb b/plugins/discourse-policy/spec/plugin_spec.rbindex 3b66114b7c7..248ae665f1f 100644--- a/plugins/discourse-policy/spec/plugin_spec.rb+++ b/plugins/discourse-policy/spec/plugin_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe DiscoursePolicy do- fab!(:user1) { Fabricate(:user) }+ fab!(:user1, :user)before { enable_current_plugin }@@ -62,7 +62,7 @@ describe DiscoursePolicy doendcontext "with add_users_to_group present" do- fab!(:group2) { Fabricate(:group) }+ fab!(:group2, :group)fab!(:post) { Fabricate(:post, user: moderator) }fab!(:policy666) dopolicy = Fabricate(:post_policy, post: post, add_users_to_group: group2.id)diff --git a/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rb b/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rbindex 6de454c34a2..8fb0b6c9d3f 100644--- a/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rb+++ b/plugins/discourse-policy/spec/reports/unaccepted_policies_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueRSpec.describe Report do- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)fab!(:group1) dogroup = Fabricate(:group)diff --git a/plugins/discourse-policy/spec/requests/policy_controller_spec.rb b/plugins/discourse-policy/spec/requests/policy_controller_spec.rbindex c0d0abac8f9..559f962d21f 100644--- a/plugins/discourse-policy/spec/requests/policy_controller_spec.rb+++ b/plugins/discourse-policy/spec/requests/policy_controller_spec.rb@@ -3,8 +3,8 @@describe DiscoursePolicy::PolicyController dofab!(:group)fab!(:moderator)- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)before doenable_current_plugin@@ -40,7 +40,7 @@ describe DiscoursePolicy::PolicyController doendcontext "when add_users_to_group is present" do- fab!(:group2) { Fabricate(:group) }+ fab!(:group2, :group)fab!(:post) { Fabricate(:post, user: moderator) }fab!(:policy666) dopolicy = Fabricate(:post_policy, post: post, add_users_to_group: group2.id)@@ -113,7 +113,7 @@ describe DiscoursePolicy::PolicyController doenddescribe "group member visibility restrictions" do- fab!(:owner) { Fabricate(:user) }+ fab!(:owner, :user)let!(:post) doraw = <<~MD[policy group=#{group.name}]diff --git a/plugins/discourse-policy/spec/serializers/post_serializer_spec.rb b/plugins/discourse-policy/spec/serializers/post_serializer_spec.rbindex 2b9841716d7..bbe11997cd3 100644--- a/plugins/discourse-policy/spec/serializers/post_serializer_spec.rb+++ b/plugins/discourse-policy/spec/serializers/post_serializer_spec.rb@@ -3,8 +3,8 @@describe PostSerializer dofab!(:group)fab!(:admin)- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)before doenable_current_plugindiff --git a/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rb b/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rbindex 8dc46127f2d..aeddbe420ae 100644--- a/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rb+++ b/plugins/discourse-post-voting/app/controllers/post_voting/comments_controller.rb@@ -88,7 +88,7 @@ module PostVotingenddef flag- RateLimiter.new(current_user, "flag_post_voting_comment", 4, 1.minutes).performed!+ RateLimiter.new(current_user, "flag_post_voting_comment", 4, 1.minute).performed!permitted_params =params.permit(%i[comment_id flag_type_id message is_warning take_action queue_for_review])diff --git a/plugins/discourse-post-voting/app/controllers/post_voting/votes_controller.rb b/plugins/discourse-post-voting/app/controllers/post_voting/votes_controller.rbindex ed324be63ba..62efb38d1b8 100644--- a/plugins/discourse-post-voting/app/controllers/post_voting/votes_controller.rb+++ b/plugins/discourse-post-voting/app/controllers/post_voting/votes_controller.rb@@ -15,7 +15,7 @@ module PostVotingif PostVoting::VoteManager.vote(@post, current_user, direction: vote_params[:direction])render json: success_jsonelse- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -31,7 +31,7 @@ module PostVoting)render json: success_jsonelse- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -59,7 +59,7 @@ module PostVotingif PostVoting::VoteManager.remove_vote(@post, current_user)render json: success_jsonelse- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendend@@ -78,7 +78,7 @@ module PostVotingif PostVoting::VoteManager.remove_vote(comment, current_user)render json: success_jsonelse- render json: failed_json, status: 422+ render json: failed_json, status: :unprocessable_entityendenddiff --git a/plugins/discourse-post-voting/plugin.rb b/plugins/discourse-post-voting/plugin.rbindex aa878fa5f81..fba651d6010 100644--- a/plugins/discourse-post-voting/plugin.rb+++ b/plugins/discourse-post-voting/plugin.rb@@ -190,7 +190,7 @@ after_initialize doregister_modifier(:topic_embed_import_create_args) do |args|category_id = args[:category]next args unless category_id- next args if args[:archetype] != Archetype.default && !args[:archetype].blank?+ next args if args[:archetype] != Archetype.default && args[:archetype].present?category = Category.find_by(id: category_id)diff --git a/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb b/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rbindex 3564cddb090..09aa62fa961 100644--- a/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb+++ b/plugins/discourse-post-voting/spec/components/post_voting/vote_manager_spec.rb@@ -2,8 +2,8 @@describe PostVoting::VoteManager dofab!(:user)- fab!(:user_2) { Fabricate(:user) }- fab!(:user_3) { Fabricate(:user) }+ fab!(:user_2, :user)+ fab!(:user_3, :user)fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }fab!(:topic_post) { Fabricate(:post, topic: topic) }fab!(:post) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-post-voting/spec/lib/post_voting/comment_review_queue_spec.rb b/plugins/discourse-post-voting/spec/lib/post_voting/comment_review_queue_spec.rbindex ace10c6866d..8a92dac52eb 100644--- a/plugins/discourse-post-voting/spec/lib/post_voting/comment_review_queue_spec.rb+++ b/plugins/discourse-post-voting/spec/lib/post_voting/comment_review_queue_spec.rb@@ -3,7 +3,7 @@describe PostVoting::CommentReviewQueue dosubject(:queue) { described_class.new }- fab!(:comment_poster) { Fabricate(:user) }+ fab!(:comment_poster, :user)fab!(:flagger) { Fabricate(:user, group_ids: [Group::AUTO_GROUPS[:trust_level_1]]) }fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }fab!(:post) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-post-voting/spec/models/post_spec.rb b/plugins/discourse-post-voting/spec/models/post_spec.rbindex 4aa66a487aa..64be20f0010 100644--- a/plugins/discourse-post-voting/spec/models/post_spec.rb+++ b/plugins/discourse-post-voting/spec/models/post_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: truedescribe Post do- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }- fab!(:user3) { Fabricate(:user) }+ fab!(:user1, :user)+ fab!(:user2, :user)+ fab!(:user3, :user)fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }fab!(:topic_post) { Fabricate(:post, topic: topic) }fab!(:post) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-post-voting/spec/models/reviewable_post_voting_comment_spec.rb b/plugins/discourse-post-voting/spec/models/reviewable_post_voting_comment_spec.rbindex 62263bb1b75..377d74c0a49 100644--- a/plugins/discourse-post-voting/spec/models/reviewable_post_voting_comment_spec.rb+++ b/plugins/discourse-post-voting/spec/models/reviewable_post_voting_comment_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe ReviewablePostVotingComment, type: :model do- fab!(:comment_poster) { Fabricate(:user) }+ fab!(:comment_poster, :user)fab!(:flagger) { Fabricate(:user, group_ids: [Group::AUTO_GROUPS[:trust_level_1]]) }fab!(:topic) { Fabricate(:topic, subtype: Topic::POST_VOTING_SUBTYPE) }fab!(:post) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-reactions/spec/reports/reactions_spec.rb b/plugins/discourse-reactions/spec/reports/reactions_spec.rbindex b9e55c5c40a..86afe4dfce0 100644--- a/plugins/discourse-reactions/spec/reports/reactions_spec.rb+++ b/plugins/discourse-reactions/spec/reports/reactions_spec.rb@@ -61,7 +61,7 @@ describe Report doexpect(report.data).to contain_exactly(a_hash_including("cat_count" => 1, :day => 2.days.ago.to_date, :like_count => 0),- a_hash_including(day: 1.days.ago.to_date, like_count: 0),+ a_hash_including(day: 1.day.ago.to_date, like_count: 0),a_hash_including("cat_count" => 1, :day => Time.current.to_date, :like_count => 0),)enddiff --git a/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb b/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rbindex 7d0257d05f4..c5558f9c528 100644--- a/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb+++ b/plugins/discourse-reactions/spec/requests/custom_reactions_controller_custom_emoji_spec.rb@@ -2,7 +2,7 @@describe DiscourseReactions::CustomReactionsController dofab!(:user)- fab!(:post_1) { Fabricate(:post) }+ fab!(:post_1, :post)let(:custom_emoji) { "wink" }diff --git a/plugins/discourse-reactions/spec/requests/custom_reactions_controller_spec.rb b/plugins/discourse-reactions/spec/requests/custom_reactions_controller_spec.rbindex b69441b3a92..ce516d58055 100644--- a/plugins/discourse-reactions/spec/requests/custom_reactions_controller_spec.rb+++ b/plugins/discourse-reactions/spec/requests/custom_reactions_controller_spec.rb@@ -613,7 +613,7 @@ describe DiscourseReactions::CustomReactionsController doDiscourseReactions::ReactionUser.count}.by(1)- freeze_time(Time.zone.now + 11.minutes)+ freeze_time(11.minutes.from_now)expect doput "/discourse-reactions/posts/#{post_1.id}/custom-reactions/hugs/toggle.json"end.to not_change { DiscourseReactions::Reaction.count }.and not_change {diff --git a/plugins/discourse-reactions/spec/services/reaction_notification_spec.rb b/plugins/discourse-reactions/spec/services/reaction_notification_spec.rbindex 6b0a848dce4..3f15b8396cd 100644--- a/plugins/discourse-reactions/spec/services/reaction_notification_spec.rb+++ b/plugins/discourse-reactions/spec/services/reaction_notification_spec.rb@@ -56,7 +56,7 @@ describe DiscourseReactions::ReactionNotification doFabricate(:reaction_user, reaction: thumbsup, user: user_2)expect { described_class.new(thumbsup, user_2).create }.not_to change { Notification.count }- freeze_time(Time.zone.now + 1.day)+ freeze_time(1.day.from_now)cry = Fabricate(:reaction, post: post_1, reaction_value: "cry")Fabricate(:reaction_user, reaction: cry, user: user_2)diff --git a/plugins/discourse-rss-polling/app/controllers/discourse_rss_polling/feed_settings_controller.rb b/plugins/discourse-rss-polling/app/controllers/discourse_rss_polling/feed_settings_controller.rbindex 0d746f14843..9ffb69e66e9 100644--- a/plugins/discourse-rss-polling/app/controllers/discourse_rss_polling/feed_settings_controller.rb+++ b/plugins/discourse-rss-polling/app/controllers/discourse_rss_polling/feed_settings_controller.rb@@ -24,10 +24,14 @@ module DiscourseRssPollingif rss_feed.saverender json: { success: true }else- render json: { success: false, errors: rss_feed.errors.full_messages }, status: 422+ render json: {+ success: false,+ errors: rss_feed.errors.full_messages,+ },+ status: :unprocessable_entityendelse- render json: { success: false, error: "Invalid feed data" }, status: 400+ render json: { success: false, error: "Invalid feed data" }, status: :bad_requestendend@@ -39,7 +43,7 @@ module DiscourseRssPollingrss_feed.destroy!render json: { success: true }else- render json: { success: false, error: "Feed not found" }, status: 404+ render json: { success: false, error: "Feed not found" }, status: :not_foundendenddiff --git a/plugins/discourse-rss-polling/spec/system/admin_spec.rb b/plugins/discourse-rss-polling/spec/system/admin_spec.rbindex ba52a281745..0d98c678ea4 100644--- a/plugins/discourse-rss-polling/spec/system/admin_spec.rb+++ b/plugins/discourse-rss-polling/spec/system/admin_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: trueRSpec.describe "Rss Polling - admin", type: :system do- fab!(:current_user) { Fabricate(:admin) }- fab!(:category_1) { Fabricate(:category) }- fab!(:tag_1) { Fabricate(:tag) }+ fab!(:current_user, :admin)+ fab!(:category_1, :category)+ fab!(:tag_1, :tag)let(:url) { "http://example.com/rss" }diff --git a/plugins/discourse-solved/spec/components/post_revisor_spec.rb b/plugins/discourse-solved/spec/components/post_revisor_spec.rbindex 2a59f455f2f..043cc98f9f5 100644--- a/plugins/discourse-solved/spec/components/post_revisor_spec.rb+++ b/plugins/discourse-solved/spec/components/post_revisor_spec.rb@@ -3,7 +3,7 @@require "post_revisor"describe PostRevisor do- fab!(:category) { Fabricate(:category_with_definition) }+ fab!(:category, :category_with_definition)fab!(:admin) { Fabricate(:admin, refresh_auto_groups: true) }fab!(:category_solved) do@@ -37,8 +37,8 @@ describe PostRevisor doSiteSetting.tagging_enabled = trueend- fab!(:tag1) { Fabricate(:tag) }- fab!(:tag2) { Fabricate(:tag) }+ fab!(:tag1, :tag)+ fab!(:tag2, :tag)fab!(:topic)let(:post) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-solved/spec/integration/solved_spec.rb b/plugins/discourse-solved/spec/integration/solved_spec.rbindex 6184939b878..32beb45e2f9 100644--- a/plugins/discourse-solved/spec/integration/solved_spec.rb+++ b/plugins/discourse-solved/spec/integration/solved_spec.rb@@ -2,7 +2,7 @@RSpec.describe "Managing Posts solved status" dolet(:topic) { Fabricate(:topic_with_op) }- fab!(:user) { Fabricate(:trust_level_4) }+ fab!(:user, :trust_level_4)let(:p1) { Fabricate(:post, topic: topic) }before { SiteSetting.allow_solved_on_all_topics = true }@@ -25,7 +25,7 @@ RSpec.describe "Managing Posts solved status" docategoryend- fab!(:solvable_tag) { Fabricate(:tag) }+ fab!(:solvable_tag, :tag)fab!(:solved_in_category) dotopic = Fabricate(:topic, category: solvable_category)@@ -48,7 +48,7 @@ RSpec.describe "Managing Posts solved status" dofab!(:unsolved_in_category) { Fabricate(:topic, category: solvable_category) }fab!(:unsolved_in_tag) { Fabricate(:topic, tags: [solvable_tag]) }- fab!(:unsolved_topic) { Fabricate(:topic) }+ fab!(:unsolved_topic, :topic)it "can filter by solved status" doexpect(@@ -265,7 +265,7 @@ RSpec.describe "Managing Posts solved status" doexpect(topic.public_topic_timer.status_type).to eq(TopicTimer.types[:silent_close])expect(topic.solved.topic_timer).to eq(topic.public_topic_timer)- expect(topic.public_topic_timer.execute_at).to eq_time(Time.zone.now + 2.hours)+ expect(topic.public_topic_timer.execute_at).to eq_time(2.hours.from_now)expect(topic.public_topic_timer.based_on_last_post).to eq(true)end@@ -287,7 +287,7 @@ RSpec.describe "Managing Posts solved status" doexpect(topic_2.public_topic_timer.status_type).to eq(TopicTimer.types[:silent_close])expect(topic_2.solved.topic_timer).to eq(topic_2.public_topic_timer)- expect(topic_2.public_topic_timer.execute_at).to eq_time(Time.zone.now + 4.hours)+ expect(topic_2.public_topic_timer.execute_at).to eq_time(4.hours.from_now)expect(topic_2.public_topic_timer.based_on_last_post).to eq(true)enddiff --git a/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb b/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rbindex 9a3d3ad0b1e..e0ddc962c18 100644--- a/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb+++ b/plugins/discourse-solved/spec/lib/guardian_extensions_spec.rb@@ -3,7 +3,7 @@describe DiscourseSolved::GuardianExtensions dofab!(:user) { Fabricate(:user, refresh_auto_groups: true) }fab!(:other_user) { Fabricate(:user, refresh_auto_groups: true) }- fab!(:topic) { Fabricate(:topic_with_op) }+ fab!(:topic, :topic_with_op)fab!(:post) { Fabricate(:post, topic: topic, user: other_user) }let(:guardian) { user.guardian }diff --git a/plugins/discourse-solved/spec/lib/topic_extension_user_deletion_spec.rb b/plugins/discourse-solved/spec/lib/topic_extension_user_deletion_spec.rbindex 74fbecd0a98..f73c782d3f4 100644--- a/plugins/discourse-solved/spec/lib/topic_extension_user_deletion_spec.rb+++ b/plugins/discourse-solved/spec/lib/topic_extension_user_deletion_spec.rb@@ -5,7 +5,7 @@ RSpec.describe DiscourseSolved::TopicExtension dofab!(:topic)fab!(:answer_post) { Fabricate(:post, topic:) }- fab!(:accepter) { Fabricate(:user) }+ fab!(:accepter, :user)describe "#accepted_answer_post_info" dolet(:solved_topic) { Fabricate(:solved_topic, topic:, answer_post:, accepter:) }diff --git a/plugins/discourse-solved/spec/models/directory_item_spec.rb b/plugins/discourse-solved/spec/models/directory_item_spec.rbindex 7b72585f3b2..45c90f8f859 100644--- a/plugins/discourse-solved/spec/models/directory_item_spec.rb+++ b/plugins/discourse-solved/spec/models/directory_item_spec.rb@@ -61,7 +61,7 @@ describe DirectoryItem, type: :model doendit "excludes solutions for silenced users" do- user.update(silenced_till: Time.zone.now + 1.day)+ user.update(silenced_till: 1.day.from_now)DiscourseSolved.accept_answer!(topic_post1, admin)@@ -77,7 +77,7 @@ describe DirectoryItem, type: :model doit "excludes solutions for suspended users" doDiscourseSolved.accept_answer!(topic_post1, admin)- user.update(suspended_till: Time.zone.now + 1.day)+ user.update(suspended_till: 1.day.from_now)DirectoryItem.refresh!diff --git a/plugins/discourse-solved/spec/requests/answer_controller_spec.rb b/plugins/discourse-solved/spec/requests/answer_controller_spec.rbindex bdcbdd63d75..39466c82972 100644--- a/plugins/discourse-solved/spec/requests/answer_controller_spec.rb+++ b/plugins/discourse-solved/spec/requests/answer_controller_spec.rb@@ -2,7 +2,7 @@describe DiscourseSolved::AnswerController dofab!(:user)- fab!(:staff_user) { Fabricate(:admin) }+ fab!(:staff_user, :admin)fab!(:category)fab!(:topic) { Fabricate(:topic, category: category) }fab!(:p) { Fabricate(:post, topic: topic) }diff --git a/plugins/discourse-solved/spec/requests/list_controller_spec.rb b/plugins/discourse-solved/spec/requests/list_controller_spec.rbindex 045da09445c..0240bb36d7c 100644--- a/plugins/discourse-solved/spec/requests/list_controller_spec.rb+++ b/plugins/discourse-solved/spec/requests/list_controller_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe ListController do- fab!(:p1) { Fabricate(:post) }+ fab!(:p1, :post)fab!(:p2) { Fabricate(:post, topic: p1.topic) }fab!(:p3) { Fabricate(:post, topic: p1.topic) }diff --git a/plugins/discourse-solved/spec/requests/solved_topics_controller_spec.rb b/plugins/discourse-solved/spec/requests/solved_topics_controller_spec.rbindex 2cd1ce2de17..8f07aaea358 100644--- a/plugins/discourse-solved/spec/requests/solved_topics_controller_spec.rb+++ b/plugins/discourse-solved/spec/requests/solved_topics_controller_spec.rb@@ -2,7 +2,7 @@describe DiscourseSolved::SolvedTopicsController dofab!(:user)- fab!(:another_user) { Fabricate(:user) }+ fab!(:another_user, :user)fab!(:admin)fab!(:topic)fab!(:post) { Fabricate(:post, topic:) }diff --git a/plugins/discourse-solved/spec/system/solved_spec.rb b/plugins/discourse-solved/spec/system/solved_spec.rbindex b39cc3e0366..27ad5bcecee 100644--- a/plugins/discourse-solved/spec/system/solved_spec.rb+++ b/plugins/discourse-solved/spec/system/solved_spec.rb@@ -2,7 +2,7 @@describe "Solved", type: :system dofab!(:admin)- fab!(:solver) { Fabricate(:user) }+ fab!(:solver, :user)fab!(:accepter) { Fabricate(:user, name: "<b>DERP<b>") }fab!(:topic) { Fabricate(:post, user: admin).topic }fab!(:solver_post) { Fabricate(:post, topic:, user: solver, cooked: "The answer is 42") }diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rbindex c5d69b95384..38b02f60e2f 100644--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin_controller.rb@@ -5,7 +5,7 @@ module DiscourseSubscriptionsrequires_plugin PLUGIN_NAMEdef index- head 200+ head :okenddef refresh_campaigndiff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rbindex 5f7b8cf0ea8..3b36d4d5183 100644--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/hooks_controller.rb@@ -36,7 +36,7 @@ module DiscourseSubscriptionsendemail = checkout_session[:customer_email]- return head 200 if checkout_session[:status] != "complete"+ return head :ok if checkout_session[:status] != "complete"return render_json_error "email not found" if !emailif checkout_session[:customer].nil?@@ -91,7 +91,7 @@ module DiscourseSubscriptionswhen "customer.subscription.updated"subscription = event[:data][:object]status = subscription[:status]- return head 200 if !%w[complete active].include?(status)+ return head :ok if !%w[complete active].include?(status)customer = find_active_customer(subscription[:customer], subscription[:plan][:product])@@ -122,7 +122,7 @@ module DiscourseSubscriptionsendend- head 200+ head :okendprivatediff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rbindex d2ae713f785..a71d9cc913a 100644--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/pricingtable_controller.rb@@ -5,7 +5,7 @@ module DiscourseSubscriptionsrequires_plugin PLUGIN_NAMEdef index- head 200+ head :okendendenddiff --git a/plugins/discourse-subscriptions/spec/serializers/site_serializer_spec.rb b/plugins/discourse-subscriptions/spec/serializers/site_serializer_spec.rbindex a2221899676..a802a8c7962 100644--- a/plugins/discourse-subscriptions/spec/serializers/site_serializer_spec.rb+++ b/plugins/discourse-subscriptions/spec/serializers/site_serializer_spec.rb@@ -18,7 +18,7 @@ describe SiteSerializer doendit "is true if the goal_met date is > 7 days old" do- Discourse.redis.set("subscriptions_goal_met_date", 1.days.ago)+ Discourse.redis.set("subscriptions_goal_met_date", 1.day.ago)data = described_class.new(Site.new(guardian), scope: guardian, root: false).as_jsonexpect(data[:show_campaign_banner]).to be truediff --git a/plugins/discourse-templates/app/models/discourse_templates/usage_count.rb b/plugins/discourse-templates/app/models/discourse_templates/usage_count.rbindex af23d0db4e1..32dcb1cafdb 100644--- a/plugins/discourse-templates/app/models/discourse_templates/usage_count.rb+++ b/plugins/discourse-templates/app/models/discourse_templates/usage_count.rb@@ -6,7 +6,7 @@ module DiscourseTemplatesbelongs_to :topic- validates_presence_of :topic_id+ validates :topic_id, presence: trueendenddiff --git a/plugins/discourse-templates/spec/lib/guardian_extension_spec.rb b/plugins/discourse-templates/spec/lib/guardian_extension_spec.rbindex db07ea8b5fd..6d759ca15eb 100644--- a/plugins/discourse-templates/spec/lib/guardian_extension_spec.rb+++ b/plugins/discourse-templates/spec/lib/guardian_extension_spec.rb@@ -7,7 +7,7 @@ describe DiscourseTemplates::GuardianExtension domoderatorendfab!(:user)- fab!(:other_user) { Fabricate(:user) }+ fab!(:other_user, :user)fab!(:group) dogroup = Fabricate(:group)Fabricate(:group_user, group: group, user: user)@@ -18,7 +18,7 @@ describe DiscourseTemplates::GuardianExtension doFabricate(:group_user, group: group, user: other_user)groupend- fab!(:discourse_templates_category) { Fabricate(:category_with_definition) }+ fab!(:discourse_templates_category, :category_with_definition)fab!(:templates_private_category) doFabricate(:private_category_with_definition, group: Group[:moderators])enddiff --git a/plugins/discourse-templates/spec/lib/topic_extension_spec.rb b/plugins/discourse-templates/spec/lib/topic_extension_spec.rbindex 6c922006321..34c77e1af4c 100644--- a/plugins/discourse-templates/spec/lib/topic_extension_spec.rb+++ b/plugins/discourse-templates/spec/lib/topic_extension_spec.rb@@ -38,13 +38,13 @@ describe DiscourseTemplates::TopicExtension dofab!(:user)context "with normal topics" do- fab!(:templates_category) { Fabricate(:category_with_definition) }+ fab!(:templates_category, :category_with_definition)fab!(:template) { Fabricate(:template_item, category: templates_category) }fab!(:templates_subcategory) doFabricate(:category_with_definition, parent_category: templates_category)endfab!(:template_on_sub) { Fabricate(:template_item, category: templates_category) }- fab!(:other_category) { Fabricate(:category_with_definition) }+ fab!(:other_category, :category_with_definition)fab!(:other_topic) { Fabricate(:topic, category: other_category) }before { SiteSetting.discourse_templates_categories = templates_category.id.to_s }@@ -65,7 +65,7 @@ describe DiscourseTemplates::TopicExtension doenddescribe "private messages" do- fab!(:other_user) { Fabricate(:user) }+ fab!(:other_user, :user)fab!(:tag_a) { Fabricate(:tag, name: "tag-a") }fab!(:tag_b) { Fabricate(:tag, name: "tag-b") }diff --git a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rbindex b249f14615b..1afd2f247d2 100644--- a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb+++ b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb@@ -11,9 +11,9 @@ describe DiscourseTemplates::TopicQueryExtension doenddescribe "list_category_templates" do- fab!(:other_category) { Fabricate(:category_with_definition) }+ fab!(:other_category, :category_with_definition)fab!(:other_topics) { Fabricate.times(5, :topic, category: other_category) }- fab!(:discourse_templates_category) { Fabricate(:category_with_definition) }+ fab!(:discourse_templates_category, :category_with_definition)fab!(:templates) doFabricate.times(100, :template_item, category: discourse_templates_category)end@@ -111,8 +111,8 @@ describe DiscourseTemplates::TopicQueryExtension doenddescribe "list_private_templates" do- fab!(:user_a) { Fabricate(:user) }- fab!(:user_b) { Fabricate(:user) }+ fab!(:user_a, :user)+ fab!(:user_b, :user)fab!(:group) dogroup = Fabricate(:group)Fabricate(:group_user, group: group, user: user)diff --git a/plugins/discourse-templates/spec/lib/user_extension_spec.rb b/plugins/discourse-templates/spec/lib/user_extension_spec.rbindex 9cfcffaea61..175247afb96 100644--- a/plugins/discourse-templates/spec/lib/user_extension_spec.rb+++ b/plugins/discourse-templates/spec/lib/user_extension_spec.rb@@ -6,7 +6,7 @@ describe DiscourseTemplates::UserExtension dofab!(:user)describe "can_use_category_templates?" do- fab!(:discourse_templates_category) { Fabricate(:category_with_definition) }+ fab!(:discourse_templates_category, :category_with_definition)fab!(:templates_private_category) doFabricate(:private_category_with_definition, group: Group[:moderators])end@@ -61,7 +61,7 @@ describe DiscourseTemplates::UserExtension doenddescribe "can_use_private_templates?" do- fab!(:other_user) { Fabricate(:user) }+ fab!(:other_user, :user)fab!(:group) dogroup = Fabricate(:group)diff --git a/plugins/discourse-templates/spec/requests/templates_controller_spec.rb b/plugins/discourse-templates/spec/requests/templates_controller_spec.rbindex 69e9cc003b0..72b1e59d187 100644--- a/plugins/discourse-templates/spec/requests/templates_controller_spec.rb+++ b/plugins/discourse-templates/spec/requests/templates_controller_spec.rb@@ -8,8 +8,8 @@ describe DiscourseTemplates::TemplatesController dofab!(:admin)fab!(:moderator)fab!(:user)- fab!(:user_in_group1) { Fabricate(:user) }- fab!(:user_in_group2) { Fabricate(:user) }+ fab!(:user_in_group1, :user)+ fab!(:user_in_group2, :user)fab!(:group1) dogroup = Fabricate(:group)group.add(user_in_group1)@@ -22,8 +22,8 @@ describe DiscourseTemplates::TemplatesController dogroup.savegroupend- fab!(:templates_parent_category) { Fabricate(:category_with_definition) }- fab!(:templates_other_parent_category) { Fabricate(:category_with_definition) }+ fab!(:templates_parent_category, :category_with_definition)+ fab!(:templates_other_parent_category, :category_with_definition)fab!(:templates_sub_category_moderators) doFabricate(:private_category_with_definition,@@ -59,9 +59,9 @@ describe DiscourseTemplates::TemplatesController dofab!(:template_item_from_other_parent) doFabricate(:template_item, category: templates_other_parent_category)end- fab!(:other_topic1) { Fabricate(:template_item) } # uncategorized- fab!(:other_topic2) { Fabricate(:template_item) } # uncategorized- fab!(:other_topic3) { Fabricate(:template_item) } # uncategorized+ fab!(:other_topic1, :template_item) # uncategorized+ fab!(:other_topic2, :template_item) # uncategorized+ fab!(:other_topic3, :template_item) # uncategorizedfab!(:tag) doFabricate(:tag,diff --git a/plugins/discourse-templates/spec/system/chat_composer_spec.rb b/plugins/discourse-templates/spec/system/chat_composer_spec.rbindex 4ecd7783b66..7521a1889f1 100644--- a/plugins/discourse-templates/spec/system/chat_composer_spec.rb+++ b/plugins/discourse-templates/spec/system/chat_composer_spec.rb@@ -1,9 +1,9 @@# frozen_string_literal: trueRSpec.describe "Inserting templates in the chat composer", type: :system do- fab!(:current_user) { Fabricate(:user) }- fab!(:other_user) { Fabricate(:user) }- fab!(:templates_category) { Fabricate(:category) }+ fab!(:current_user, :user)+ fab!(:other_user, :user)+ fab!(:templates_category, :category)fab!(:template_simple) { Fabricate(:template_item, category: templates_category) }fab!(:template_variables) doFabricate(@@ -13,7 +13,7 @@ RSpec.describe "Inserting templates in the chat composer", type: :system do)end- fab!(:channel_1) { Fabricate(:chat_channel) }+ fab!(:channel_1, :chat_channel)fab!(:message_1) doFabricate(:chat_message, user: current_user, chat_channel: channel_1, use_service: true)enddiff --git a/plugins/discourse-topic-voting/spec/lib/topic_query_spec.rb b/plugins/discourse-topic-voting/spec/lib/topic_query_spec.rbindex fc47f7142e8..ce3d6fbb1f0 100644--- a/plugins/discourse-topic-voting/spec/lib/topic_query_spec.rb+++ b/plugins/discourse-topic-voting/spec/lib/topic_query_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: truedescribe TopicQuery do- fab!(:user0) { Fabricate(:user) }- fab!(:category1) { Fabricate(:category) }+ fab!(:user0, :user)+ fab!(:category1, :category)fab!(:topic0) { Fabricate(:topic, category: category1) }fab!(:topic1) { Fabricate(:topic, category: category1) }fab!(:vote) { DiscourseTopicVoting::Vote.create!(topic_id: topic1.id, user_id: user0.id) }diff --git a/plugins/discourse-topic-voting/spec/requests/lists_controller_spec.rb b/plugins/discourse-topic-voting/spec/requests/lists_controller_spec.rbindex 2101ae5b74e..300988b166b 100644--- a/plugins/discourse-topic-voting/spec/requests/lists_controller_spec.rb+++ b/plugins/discourse-topic-voting/spec/requests/lists_controller_spec.rb@@ -25,8 +25,8 @@ describe ListController doendcontext "in a category" do- fab!(:category1) { Fabricate(:category) }- fab!(:category2) { Fabricate(:category) }+ fab!(:category1, :category)+ fab!(:category2, :category)fab!(:topic1) doFabricate(:topic, category: category1, title: "Topic in votes-enabled category 1")enddiff --git a/plugins/discourse-topic-voting/spec/system/voting_spec.rb b/plugins/discourse-topic-voting/spec/system/voting_spec.rbindex 00d96690cdd..106ee0f78c1 100644--- a/plugins/discourse-topic-voting/spec/system/voting_spec.rb+++ b/plugins/discourse-topic-voting/spec/system/voting_spec.rb@@ -3,8 +3,8 @@RSpec.describe "Topic voting", type: :system dofab!(:user)fab!(:admin) { Fabricate(:admin, trust_level: TrustLevel[4]) }- fab!(:category1) { Fabricate(:category) }- fab!(:category2) { Fabricate(:category) }+ fab!(:category1, :category)+ fab!(:category2, :category)fab!(:topic1) { Fabricate(:topic, category: category1) }fab!(:topic2) { Fabricate(:topic, category: category1) }fab!(:topic3) { Fabricate(:topic, category: category2) }diff --git a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rbindex 6d803bc9000..8cec99bcee5 100644--- a/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb+++ b/plugins/discourse-zendesk-plugin/app/controllers/discourse_zendesk_plugin/sync_controller.rb@@ -16,7 +16,7 @@ module DiscourseZendeskPlugindef webhookunless SiteSetting.zendesk_enabled? && SiteSetting.sync_comments_from_zendesk- return render json: failed_json, status: 422+ return render json: failed_json, status: :unprocessable_entityendticket_id = params[:ticket_id]diff --git a/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb b/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rbindex fd93fae3c2a..b573a97f9a5 100644--- a/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb+++ b/plugins/discourse-zendesk-plugin/lib/discourse_zendesk_plugin/helper.rb@@ -96,7 +96,7 @@ module DiscourseZendeskPluginresult = zendesk_client.users.search(query: user.email)return result.first if result.present? && result.size == 1zendesk_client.users.create(- name: (user.name.present? ? user.name : user.username),+ name: user.name.presence || user.username,email: user.email,verified: true,role: "end-user",diff --git a/plugins/discourse-zendesk-plugin/spec/integration/topic_extensions_spec.rb b/plugins/discourse-zendesk-plugin/spec/integration/topic_extensions_spec.rbindex 5c4a2a8cedd..f613d9de1b9 100644--- a/plugins/discourse-zendesk-plugin/spec/integration/topic_extensions_spec.rb+++ b/plugins/discourse-zendesk-plugin/spec/integration/topic_extensions_spec.rb@@ -7,7 +7,7 @@ describe "TopicExtensions" dofab!(:topic_1) { Fabricate(:topic, user: user_1) }context "when an enabled category is set on the topic" do- fab!(:category_1) { Fabricate(:category) }+ fab!(:category_1, :category)before { SiteSetting.zendesk_autogenerate_categories = "#{category_1.id}" }@@ -17,7 +17,7 @@ describe "TopicExtensions" doargs: {topic_id: topic_1.id,},- at: Time.zone.now + 5.seconds,+ at: 5.seconds.from_now,) dotopic_1.category = category_1topic_1.save!@@ -36,7 +36,7 @@ describe "TopicExtensions" doargs: {topic_id: topic_1.id,},- at: Time.zone.now + 5.seconds,+ at: 5.seconds.from_now,) dotopic_1.category = niltopic_1.save!diff --git a/script/bulk_import/discourse_merger.rb b/script/bulk_import/discourse_merger.rbindex 7cd39298102..c2331096c85 100644--- a/script/bulk_import/discourse_merger.rb+++ b/script/bulk_import/discourse_merger.rb@@ -797,7 +797,7 @@ class BulkImport::DiscourseMerger < BulkImport::Baseprocessed =(if respond_to?(process_method_name)- send(process_method_name, HashWithIndifferentAccess.new(row))+ send(process_method_name, ActiveSupport::HashWithIndifferentAccess.new(row))elserowenddiff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rbindex 211578e9369..ef4b0fb36ad 100644--- a/script/import_scripts/discuz_x.rb+++ b/script/import_scripts/discuz_x.rb@@ -212,7 +212,7 @@ class ImportScripts::DiscuzX < ImportScripts::Basefirst_exists(user["address"],(- if !user["resideprovince"].blank?+ if user["resideprovince"].present?[user["resideprovince"],user["residecity"],@@ -250,7 +250,8 @@ class ImportScripts::DiscuzX < ImportScripts::Baseendendend- if !user["spacecss"].blank? && newmember.user_profile.profile_background_upload.blank?+ if user["spacecss"].present? &&+ newmember.user_profile.profile_background_upload.blank?# profile backgroundif matched = user["spacecss"].match(/body\s*{[^}]*url\('?(.+?)'?\)/i)body_background = matched[1].split(ORIGINAL_SITE_PREFIX, 2).last@@ -310,7 +311,7 @@ class ImportScripts::DiscuzX < ImportScripts::Baseif newmember.email_digestsnewmember.update(email_digests: user["email_confirmed"] == 1)end- if !newmember.name.blank? && newmember.name == (newmember.username)+ if newmember.name.present? && newmember.name == (newmember.username)newmember.update(name: "")endend,@@ -341,8 +342,8 @@ class ImportScripts::DiscuzX < ImportScripts::Basemax_position = Category.all.max_by(&:position).positioncreate_categories(results) do |row|next if row["type"] == ("group") || row["status"] == (2) # or row['status'].to_i == 3 # 如果不想导入群组,取消注释- extra = PHP.unserialize(row["extra"]) if !row["extra"].blank?- color = extra["namecolor"][1, 6] if extra && !extra["namecolor"].blank?+ extra = PHP.unserialize(row["extra"]) if row["extra"].present?+ color = extra["namecolor"][1, 6] if extra && extra["namecolor"].present?Category.all.max_by(&:position).position@@ -1156,7 +1157,7 @@ class ImportScripts::DiscuzX < ImportScripts::Baseenddef first_exists(*items)- items.find { |item| !item.blank? } || ""+ items.find { |item| item.present? } || ""enddef mysql_query(sql)diff --git a/script/import_scripts/jforum.rb b/script/import_scripts/jforum.rbindex 4ca82a2fe00..fc407a425b8 100644--- a/script/import_scripts/jforum.rb+++ b/script/import_scripts/jforum.rb@@ -89,7 +89,7 @@ class ImportScripts::JForum < ImportScripts::Basedef user_fields@user_fields ||=begin- Hash[UserField.all.map { |field| [field.name, field] }]+ UserField.all.index_by(&:name)endenddiff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rbindex 1e043d37a74..140e434d0ce 100644--- a/script/import_scripts/mybb.rb+++ b/script/import_scripts/mybb.rb@@ -87,7 +87,7 @@ class ImportScripts::MyBB < ImportScripts::Baseavatar_url: avatar_url,post_create_action:proc do |newuser|- if !user["avatar"].blank?+ if user["avatar"].present?avatar = user["avatar"].gsub(/\?.*/, "")if avatar.match(/^http.*/)UserAvatar.import_url_for_user(avatar, newuser)diff --git a/script/import_scripts/phpbb3/importers/post_importer.rb b/script/import_scripts/phpbb3/importers/post_importer.rbindex 4f66560e349..6c5470d702b 100644--- a/script/import_scripts/phpbb3/importers/post_importer.rb+++ b/script/import_scripts/phpbb3/importers/post_importer.rb@@ -31,8 +31,7 @@ module ImportScripts::PhpBB3def map_post(row)return if @settings.category_mappings.dig(row[:forum_id].to_s, :skip)- imported_user_id =- @settings.prefix(row[:post_username].blank? ? row[:poster_id] : row[:post_username])+ imported_user_id = @settings.prefix(row[:post_username].presence || row[:poster_id])user_id = @lookup.user_id_from_imported_user_id(imported_user_id) || -1is_first_post = row[:post_id] == row[:topic_first_post_id]diff --git a/script/import_scripts/phpbb3/importers/user_importer.rb b/script/import_scripts/phpbb3/importers/user_importer.rbindex 6f32223232c..d363c1bef5d 100644--- a/script/import_scripts/phpbb3/importers/user_importer.rb+++ b/script/import_scripts/phpbb3/importers/user_importer.rb@@ -108,7 +108,7 @@ module ImportScripts::PhpBB3def user_fields@user_fields ||=begin- Hash[UserField.all.map { |field| [field.name, field] }]+ UserField.all.index_by(&:name)endend@@ -152,8 +152,7 @@ module ImportScripts::PhpBB3if row[:user_inactive_reason] == Constants::INACTIVE_MANUALuser.suspended_at = Time.nowuser.suspended_till = 200.years.from_now- ban_reason =- row[:ban_reason].blank? ? "Account deactivated by administrator" : row[:ban_reason] # TODO i18n+ ban_reason = row[:ban_reason].presence || "Account deactivated by administrator" # TODO i18nelsif row[:ban_start].present?user.suspended_at = Time.zone.at(row[:ban_start])user.suspended_till = row[:ban_end] > 0 ? Time.zone.at(row[:ban_end]) : 200.years.from_nowdiff --git a/script/import_scripts/phpbb3/support/settings.rb b/script/import_scripts/phpbb3/support/settings.rbindex e308e322cf5..cee09d6970c 100644--- a/script/import_scripts/phpbb3/support/settings.rb+++ b/script/import_scripts/phpbb3/support/settings.rb@@ -50,7 +50,7 @@ module ImportScripts::PhpBB3@new_categories = import_settings["new_categories"]@category_mappings =- import_settings.fetch("category_mappings", []).to_h { |m| [m[:source_category_id].to_s, m] }+ import_settings.fetch("category_mappings", []).index_by { _1[:source_category_id].to_s }@tag_mappings = import_settings["tag_mappings"]@rank_mapping = import_settings["rank_mapping"]diff --git a/script/import_scripts/vbulletin3.rb b/script/import_scripts/vbulletin3.rbindex 71ec3ec8d59..1eb6ff3f711 100644--- a/script/import_scripts/vbulletin3.rb+++ b/script/import_scripts/vbulletin3.rb@@ -717,7 +717,7 @@ LEFT OUTER JOIN #{TABLE_PREFIX}avatar a ON a.avatarid = u.avataridputs "", "creating category moderator groups..."forums = mysql_query("SELECT forumid, parentid, title FROM #{TABLE_PREFIX}forum").to_aforums.each { |f| f["children"] = forums.select { |c| c["parentid"] == f["forumid"] } }- forum_map = forums.map { |f| [f["forumid"], f] }.to_h+ forum_map = forums.index_by { _1["forumid"] }modentries = mysql_query(<<-SQL).to_aSELECT m.forumid, m.userid, u.usergroupid IN (5,6) is_staffFROM #{TABLE_PREFIX}moderator mdiff --git a/script/import_scripts/yammer.rb b/script/import_scripts/yammer.rbindex e7aa3f447b4..0530b66eede 100644--- a/script/import_scripts/yammer.rb+++ b/script/import_scripts/yammer.rb@@ -228,7 +228,7 @@ class ImportScripts::Yammer < ImportScripts::Basedef import_categoriesputs "", "creating categories"parent_category = nil- if !PARENT_CATEGORY_NAME.blank?+ if PARENT_CATEGORY_NAME.present?parent_category = Category.find_by(name: PARENT_CATEGORY_NAME)parent_category =Category.create(@@ -310,13 +310,7 @@ class ImportScripts::Yammer < ImportScripts::Base{id: import_topic_id(row["id"]),title:- (- if row["title"].present?- row["title"]- else- row["raw"].split(/\W/)[0..(NUM_WORDS_IN_TITLE - 1)].join(" ")- end- ),+ row["title"].presence || row["raw"].split(/\W/)[0..(NUM_WORDS_IN_TITLE - 1)].join(" "),raw: normalize_raw(row["raw"]),category:(@@ -369,13 +363,7 @@ class ImportScripts::Yammer < ImportScripts::Base{id: import_topic_id(row["id"]),title:- (- if row["title"].present?- row["title"]- else- row["raw"].split(/\W/)[0..(NUM_WORDS_IN_TITLE - 1)].join(" ")- end- ),+ row["title"].presence || row["raw"].split(/\W/)[0..(NUM_WORDS_IN_TITLE - 1)].join(" "),raw: normalize_raw(row["raw"]),category:(diff --git a/script/profile_db_generator.rb b/script/profile_db_generator.rbindex b3b1e759b6d..7631754cecc 100644--- a/script/profile_db_generator.rb+++ b/script/profile_db_generator.rb@@ -62,7 +62,7 @@ require_relative "../config/environment"Jobs.run_immediately!-unless Rails.env == "profile"+unless Rails.env.profile?puts "This script should only be used in the profile environment"exitenddiff --git a/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb b/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rbindex 51b34629875..7c3b9dde0a2 100644--- a/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb+++ b/spec/db/migrate/20250714010001_backfill_themeable_site_settings_spec.rb@@ -3,8 +3,8 @@require Rails.root.join("db/migrate/20250714010001_backfill_themeable_site_settings.rb")RSpec.describe BackfillThemeableSiteSettings do- fab!(:theme_1) { Fabricate(:theme) }- fab!(:theme_2) { Fabricate(:theme) }+ fab!(:theme_1, :theme)+ fab!(:theme_2, :theme)fab!(:theme_3) { Fabricate(:theme, component: true) }before dodiff --git a/spec/fabricators/bookmark_fabricator.rb b/spec/fabricators/bookmark_fabricator.rbindex ba9271a22e2..74a384a1fee 100644--- a/spec/fabricators/bookmark_fabricator.rb+++ b/spec/fabricators/bookmark_fabricator.rb@@ -12,11 +12,11 @@ Fabricator(:bookmark_next_business_day_reminder, from: :bookmark) doreminder_at dodate =if Time.zone.now.friday?- Time.zone.now + 3.days+ 3.days.from_nowelsif Time.zone.now.saturday?- Time.zone.now + 2.days+ 2.days.from_nowelse- Time.zone.now + 1.day+ 1.day.from_nowenddate.iso8601enddiff --git a/spec/jobs/bookmark_reminder_notifications_spec.rb b/spec/jobs/bookmark_reminder_notifications_spec.rbindex 7316d64034b..655c44e8628 100644--- a/spec/jobs/bookmark_reminder_notifications_spec.rb+++ b/spec/jobs/bookmark_reminder_notifications_spec.rb@@ -4,7 +4,7 @@ RSpec.describe Jobs::BookmarkReminderNotifications dosubject(:job) { described_class.new }fab!(:user)- let(:five_minutes_ago) { Time.zone.now - 5.minutes }+ let(:five_minutes_ago) { 5.minutes.ago }let(:bookmark1) { Fabricate(:bookmark, user: user) }let(:bookmark2) { Fabricate(:bookmark, user: user) }let(:bookmark3) { Fabricate(:bookmark, user: user) }@@ -30,7 +30,7 @@ RSpec.describe Jobs::BookmarkReminderNotifications doit "will not send a reminder for a bookmark in the future" dofreeze_time- bookmark4 = Fabricate(:bookmark, reminder_at: Time.zone.now + 1.day)+ bookmark4 = Fabricate(:bookmark, reminder_at: 1.day.from_now)expect { job.execute }.to change { Notification.where(user: user).count }.by(3)expect(bookmark1.reload.reminder_last_sent_at).to eq_time(Time.zone.now)expect(bookmark2.reload.reminder_last_sent_at).to eq_time(Time.zone.now)diff --git a/spec/jobs/check_new_features_spec.rb b/spec/jobs/check_new_features_spec.rbindex 1caa61046f6..fd6bb7048ff 100644--- a/spec/jobs/check_new_features_spec.rb+++ b/spec/jobs/check_new_features_spec.rb@@ -10,7 +10,7 @@ RSpec.describe Jobs::CheckNewFeatures dodescription: "",link: "https://meta.discourse.org/t/-/238821",created_at: created_at.iso8601,- updated_at: (created_at + 1.minutes).iso8601,+ updated_at: (created_at + 1.minute).iso8601,discourse_version: discourse_version,}enddiff --git a/spec/jobs/clean_dismissed_topic_users_spec.rb b/spec/jobs/clean_dismissed_topic_users_spec.rbindex b6e411814bb..9dc48055b43 100644--- a/spec/jobs/clean_dismissed_topic_users_spec.rb+++ b/spec/jobs/clean_dismissed_topic_users_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueRSpec.describe Jobs::CleanDismissedTopicUsers do- fab!(:user) { Fabricate(:user, created_at: 1.days.ago, previous_visit_at: 1.days.ago) }+ fab!(:user) { Fabricate(:user, created_at: 1.day.ago, previous_visit_at: 1.day.ago) }fab!(:topic) { Fabricate(:topic, created_at: 5.hours.ago) }fab!(:dismissed_topic_user) { Fabricate(:dismissed_topic_user, user: user, topic: topic) }@@ -15,7 +15,7 @@ RSpec.describe Jobs::CleanDismissedTopicUsers douser.user_option.update(new_topic_duration_minutes: User::NewTopicDuration::LAST_VISIT)expect { described_class.new.execute({}) }.not_to change { DismissedTopicUser.count }- user.update!(previous_visit_at: 1.hours.ago)+ user.update!(previous_visit_at: 1.hour.ago)expect { described_class.new.execute({}) }.to change { DismissedTopicUser.count }.by(-1)end@@ -29,7 +29,7 @@ RSpec.describe Jobs::CleanDismissedTopicUsers doenddescribe "#delete_over_the_limit_dismissals!" do- fab!(:user2) { Fabricate(:user, created_at: 1.days.ago, previous_visit_at: 1.days.ago) }+ fab!(:user2) { Fabricate(:user, created_at: 1.day.ago, previous_visit_at: 1.day.ago) }fab!(:topic2) { Fabricate(:topic, created_at: 6.hours.ago) }fab!(:topic3) { Fabricate(:topic, created_at: 2.hours.ago) }fab!(:dismissed_topic_user2) { Fabricate(:dismissed_topic_user, user: user, topic: topic2) }diff --git a/spec/jobs/clean_up_user_api_keys_max_life_spec.rb b/spec/jobs/clean_up_user_api_keys_max_life_spec.rbindex a000e908712..de60bfc8391 100644--- a/spec/jobs/clean_up_user_api_keys_max_life_spec.rb+++ b/spec/jobs/clean_up_user_api_keys_max_life_spec.rb@@ -4,7 +4,7 @@ RSpec.describe Jobs::CleanUpUserApiKeysMaxLife dofab!(:older_key) { Fabricate(:readonly_user_api_key, created_at: 3.days.ago) }fab!(:newer_key) { Fabricate(:readonly_user_api_key, created_at: 1.day.ago) }fab!(:revoked_key) do- Fabricate(:readonly_user_api_key, created_at: 4.day.ago, revoked_at: 1.day.ago)+ Fabricate(:readonly_user_api_key, created_at: 4.days.ago, revoked_at: 1.day.ago)endcontext "when user api key was created before the max life period" dodiff --git a/spec/jobs/delete_replies_spec.rb b/spec/jobs/delete_replies_spec.rbindex 7dfb7b62b22..b52545903f9 100644--- a/spec/jobs/delete_replies_spec.rb+++ b/spec/jobs/delete_replies_spec.rb@@ -27,7 +27,7 @@ RSpec.describe Jobs::DeleteReplies do}.by(-2)topic_timer.reload- expect(topic_timer.execute_at).to eq_time(2.day.from_now)+ expect(topic_timer.execute_at).to eq_time(2.days.from_now)endit "does not delete posts with likes over the threshold" dodiff --git a/spec/jobs/export_csv_file_spec.rb b/spec/jobs/export_csv_file_spec.rbindex 65d89c6832e..08d59597abd 100644--- a/spec/jobs/export_csv_file_spec.rb+++ b/spec/jobs/export_csv_file_spec.rb@@ -90,8 +90,8 @@ RSpec.describe Jobs::ExportCsvFile doentity: "staff_action",args: {# Fine-tuning for 1 minute to ensure we capture the correct range- start_date: (5.days.ago - 1.minutes).iso8601,- end_date: (2.days.ago + 1.minutes).iso8601,+ start_date: (5.days.ago - 1.minute).iso8601,+ end_date: (2.days.ago + 1.minute).iso8601,},)end.to change { Upload.count }.by(1)@@ -119,7 +119,9 @@ RSpec.describe Jobs::ExportCsvFile do.expects(:staff_action_records).with(admin,- HashWithIndifferentAccess.new("action_id" => UserHistory.actions[:suspend_user].to_s),+ ActiveSupport::HashWithIndifferentAccess.new(+ "action_id" => UserHistory.actions[:suspend_user].to_s,+ ),).returns(res)@@ -148,7 +150,10 @@ RSpec.describe Jobs::ExportCsvFile doexporter = Jobs::ExportCsvFile.newexporter.entity = "report"exporter.extra =- HashWithIndifferentAccess.new(start_date: "2010-01-01", end_date: "2011-01-01")+ ActiveSupport::HashWithIndifferentAccess.new(+ start_date: "2010-01-01",+ end_date: "2011-01-01",+ )exporter.current_user = User.find_by(id: user.id)exporterenddiff --git a/spec/jobs/export_user_archive_spec.rb b/spec/jobs/export_user_archive_spec.rbindex e1eedbbf9b6..d7f13c3d79a 100644--- a/spec/jobs/export_user_archive_spec.rb+++ b/spec/jobs/export_user_archive_spec.rb@@ -344,7 +344,7 @@ RSpec.describe Jobs::ExportUserArchive dobookmark1 =manager.create_for(bookmarkable_id: post1.id, bookmarkable_type: "Post", name: name)- update1_at = now + 1.hours+ update1_at = now + 1.hourbookmark1.update(name: "great food recipe", updated_at: update1_at)manager.create_for(diff --git a/spec/jobs/jobs_base_spec.rb b/spec/jobs/jobs_base_spec.rbindex 42630bf13a2..835d4b535a3 100644--- a/spec/jobs/jobs_base_spec.rb+++ b/spec/jobs/jobs_base_spec.rb@@ -111,7 +111,10 @@ RSpec.describe ::Jobs::Base doendit "converts to an indifferent access hash" do- ::Jobs::Base.any_instance.expects(:execute).with(instance_of(HashWithIndifferentAccess))+ ::Jobs::Base+ .any_instance+ .expects(:execute)+ .with(instance_of(ActiveSupport::HashWithIndifferentAccess))::Jobs::Base.new.perform("hello" => "world")enddiff --git a/spec/jobs/old_keys_reminder_spec.rb b/spec/jobs/old_keys_reminder_spec.rbindex f2ccae695d6..c2a70884e51 100644--- a/spec/jobs/old_keys_reminder_spec.rb+++ b/spec/jobs/old_keys_reminder_spec.rb@@ -48,9 +48,9 @@ RSpec.describe Jobs::OldKeysReminder doAs a courtesy, we wanted to let you know that the following credentials used on your Discourse instance have not been updated in more than two years:- google_oauth2_client_secret - #{google_secret.updated_at.to_date.to_fs(:db)}- github_client_secret - #{github_secret.updated_at.to_date.to_fs(:db)}- api key description - #{api_key.created_at.to_date.to_fs(:db)}+ google_oauth2_client_secret - #{google_secret.updated_at.to_date.to_formatted_s(:db)}+ github_client_secret - #{github_secret.updated_at.to_date.to_formatted_s(:db)}+ api key description - #{api_key.created_at.to_date.to_formatted_s(:db)}No action is required at this time, however, it is considered good security practice to cycle all your important credentials every few years.TEXT@@ -65,11 +65,11 @@ RSpec.describe Jobs::OldKeysReminder doAs a courtesy, we wanted to let you know that the following credentials used on your Discourse instance have not been updated in more than two years:- google_oauth2_client_secret - #{google_secret.updated_at.to_date.to_fs(:db)}- github_client_secret - #{github_secret.updated_at.to_date.to_fs(:db)}- twitter_consumer_secret - #{recent_twitter_secret.updated_at.to_date.to_fs(:db)}- api key description - #{api_key.created_at.to_date.to_fs(:db)}- recent api key description - #{admin.username} - #{recent_api_key.created_at.to_date.to_fs(:db)}+ google_oauth2_client_secret - #{google_secret.updated_at.to_date.to_formatted_s(:db)}+ github_client_secret - #{github_secret.updated_at.to_date.to_formatted_s(:db)}+ twitter_consumer_secret - #{recent_twitter_secret.updated_at.to_date.to_formatted_s(:db)}+ api key description - #{api_key.created_at.to_date.to_formatted_s(:db)}+ recent api key description - #{admin.username} - #{recent_api_key.created_at.to_date.to_formatted_s(:db)}No action is required at this time, however, it is considered good security practice to cycle all your important credentials every few years.TEXT@@ -88,7 +88,7 @@ RSpec.describe Jobs::OldKeysReminder doexpect { described_class.new.execute({}) }.to change { Post.count }.by(1)Topic.last.trash!expect { described_class.new.execute({}) }.not_to change { Post.count }- freeze_time 1.years.from_now+ freeze_time 1.year.from_nowexpect { described_class.new.execute({}) }.not_to change { Post.count }freeze_time 3.days.from_nowexpect { described_class.new.execute({}) }.to change { Post.count }.by(1)diff --git a/spec/jobs/process_shelved_notifications_spec.rb b/spec/jobs/process_shelved_notifications_spec.rbindex 575e1b4b9c5..4292eead2be 100644--- a/spec/jobs/process_shelved_notifications_spec.rb+++ b/spec/jobs/process_shelved_notifications_spec.rb@@ -8,7 +8,7 @@ RSpec.describe Jobs::ProcessShelvedNotifications doit "removes all past do not disturb timings" dofuture = Fabricate(:do_not_disturb_timing, ends_at: 1.day.from_now)- past = Fabricate(:do_not_disturb_timing, starts_at: 2.day.ago, ends_at: 1.minute.ago)+ past = Fabricate(:do_not_disturb_timing, starts_at: 2.days.ago, ends_at: 1.minute.ago)expect { job.execute({}) }.to change { DoNotDisturbTiming.count }.by(-1)expect(DoNotDisturbTiming.find_by(id: future.id)).to eq(future)@@ -42,7 +42,7 @@ RSpec.describe Jobs::ProcessShelvedNotifications dodata: "{}",notification_type: 1,)- user.do_not_disturb_timings.last.update(ends_at: 1.days.ago)+ user.do_not_disturb_timings.last.update(ends_at: 1.day.ago)expect(notification.shelved_notification).to be_presentjob.execute({})diff --git a/spec/jobs/topic_timer_enqueuer_spec.rb b/spec/jobs/topic_timer_enqueuer_spec.rbindex 1d8fa534b3c..c2bf80b7640 100644--- a/spec/jobs/topic_timer_enqueuer_spec.rb+++ b/spec/jobs/topic_timer_enqueuer_spec.rb@@ -22,7 +22,7 @@ RSpec.describe Jobs::TopicTimerEnqueuer dofab!(:future_timer) doFabricate(:topic_timer,- execute_at: 1.hours.from_now,+ execute_at: 1.hour.from_now,created_at: 1.hour.ago,status_type: TopicTimer.types[:close],)@@ -60,7 +60,7 @@ RSpec.describe Jobs::TopicTimerEnqueuer doit "does not re-enqueue a job that has already been scheduled ahead of time in sidekiq (legacy topic timers)" doexpect_not_enqueued_with(job: :close_topic, args: { topic_timer_id: timer1.id })- Jobs.enqueue_at(1.hours.from_now, :close_topic, topic_timer_id: timer1.id)+ Jobs.enqueue_at(1.hour.from_now, :close_topic, topic_timer_id: timer1.id)job.executeenddiff --git a/spec/lib/guardian/post_guardian_spec.rb b/spec/lib/guardian/post_guardian_spec.rbindex 30afbcc801d..68955e4bd77 100644--- a/spec/lib/guardian/post_guardian_spec.rb+++ b/spec/lib/guardian/post_guardian_spec.rb@@ -5,7 +5,7 @@ RSpec.describe PostGuardian dofab!(:user) { Fabricate(:user, refresh_auto_groups: true) }fab!(:anon, :anonymous)fab!(:admin)- fab!(:another_admin) { Fabricate(:admin) }+ fab!(:another_admin, :admin)fab!(:moderator)fab!(:trust_level_0) { Fabricate(:trust_level_0, refresh_auto_groups: true) }fab!(:trust_level_4) { Fabricate(:trust_level_4, refresh_auto_groups: true) }diff --git a/spec/lib/guardian/user_guardian_spec.rb b/spec/lib/guardian/user_guardian_spec.rbindex 5b1b2030631..1ebfce2c144 100644--- a/spec/lib/guardian/user_guardian_spec.rb+++ b/spec/lib/guardian/user_guardian_spec.rb@@ -437,7 +437,7 @@ RSpec.describe UserGuardian douser.user_stat = UserStat.new(new_since: 3.days.ago, first_post_created_at: 1.day.ago)expect(guardian.can_delete_user?(user)).to eq(true)- user.user_stat = UserStat.new(new_since: 3.days.ago, first_post_created_at: 3.day.ago)+ user.user_stat = UserStat.new(new_since: 3.days.ago, first_post_created_at: 3.days.ago)expect(guardian.can_delete_user?(user)).to eq(false)endend@@ -448,7 +448,7 @@ RSpec.describe UserGuardian doit "is allowed when even when user created the first post before delete_user_max_post_age days" doSiteSetting.delete_user_max_post_age = 2- user.user_stat = UserStat.new(new_since: 3.days.ago, first_post_created_at: 3.day.ago)+ user.user_stat = UserStat.new(new_since: 3.days.ago, first_post_created_at: 3.days.ago)expect(guardian.can_delete_user?(user)).to eq(true)endenddiff --git a/spec/lib/hijack_spec.rb b/spec/lib/hijack_spec.rbindex 84d949e83a0..cc3cd1124d8 100644--- a/spec/lib/hijack_spec.rb+++ b/spec/lib/hijack_spec.rb@@ -45,7 +45,7 @@ RSpec.describe Hijack doapp =lambda do |env|tester = Hijack::Tester.new(env)- tester.hijack_test { render body: "hello", status: 201 }+ tester.hijack_test { render body: "hello", status: :created }endenv = create_request_env(path: "/")@@ -64,7 +64,7 @@ RSpec.describe Hijack dotester.hijack_test docopy_req = request- render body: "hello world", status: 200+ render body: "hello world", status: :okendexpect(copy_req.object_id).not_to eq(orig_req.object_id)@@ -77,7 +77,7 @@ RSpec.describe Hijack doapp =lambda do |env|tester = Hijack::Tester.new(env)- tester.hijack_test { render body: "hello", status: 201 }+ tester.hijack_test { render body: "hello", status: :created }expect(tester.io.string).to include("Access-Control-Allow-Origin: www.rainbows.com")end@@ -112,7 +112,7 @@ RSpec.describe Hijack doapp =lambda do |env|tester = Hijack::Tester.new(env)- tester.hijack_test { render body: "hello", status: 201 }+ tester.hijack_test { render body: "hello", status: :created }expect(tester.io.string).to include("Access-Control-Allow-Origin: https://www.rainbows.com")end@@ -144,7 +144,7 @@ RSpec.describe Hijack dotester.response.headers["Hello-World"] = "sam"tester.hijack_test doexpires_in 1.year- render body: "hello world", status: 402+ render body: "hello world", status: :payment_requiredendexpect(tester.io.string).to include("Hello-World: sam")@@ -153,14 +153,14 @@ RSpec.describe Hijack doit "handles expires_in" dotester.hijack_test doexpires_in 1.year- render body: "hello world", status: 402+ render body: "hello world", status: :payment_requiredendexpect(tester.io.string).to include("max-age=31556952")endit "renders non 200 status if asked for" do- tester.hijack_test { render body: "hello world", status: 402 }+ tester.hijack_test { render body: "hello world", status: :payment_required }expect(tester.io.string).to include("402")expect(tester.io.string).to include("world")diff --git a/spec/lib/js_locale_helper_spec.rb b/spec/lib/js_locale_helper_spec.rbindex 685d3dabd4a..4142f3cd4c6 100644--- a/spec/lib/js_locale_helper_spec.rb+++ b/spec/lib/js_locale_helper_spec.rb@@ -28,7 +28,7 @@ RSpec.describe JsLocaleHelper domodule StubLoadTranslationsdef set_translations(locale, translations)- @loaded_translations ||= HashWithIndifferentAccess.new+ @loaded_translations ||= ActiveSupport::HashWithIndifferentAccess.new@loaded_translations[locale] = translationsenddiff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rbindex 68636d0ba7a..b14a0cd83f4 100644--- a/spec/lib/post_creator_spec.rb+++ b/spec/lib/post_creator_spec.rb@@ -461,8 +461,8 @@ RSpec.describe PostCreator doFabricate(:topic_timer,based_on_last_post: true,- execute_at: Time.zone.now - 12.hours,- created_at: Time.zone.now - 24.hours,+ execute_at: 12.hours.ago,+ created_at: 24.hours.ago,duration_minutes: 12 * 60,)end@@ -479,7 +479,7 @@ RSpec.describe PostCreator dotopic_timer.reload- expect(topic_timer.execute_at).to eq_time(Time.zone.now + 12.hours)+ expect(topic_timer.execute_at).to eq_time(12.hours.from_now)expect(topic_timer.created_at).to eq_time(Time.zone.now)end@@ -952,7 +952,7 @@ RSpec.describe PostCreator docoding_horror,raw: "first post in topic",topic_id: topic.id,- created_at: Time.zone.now - 24.hours,+ created_at: 24.hours.ago,).createenddiff --git a/spec/lib/post_revisor_spec.rb b/spec/lib/post_revisor_spec.rbindex 5a18110cce3..eef2f2ef646 100644--- a/spec/lib/post_revisor_spec.rb+++ b/spec/lib/post_revisor_spec.rb@@ -533,7 +533,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)# "roll back"post_revisor.revise!(@@ -1605,7 +1605,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.not_to change { post.topic.bumped_at }end@@ -1616,7 +1616,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.not_to change { post.topic.bumped_at }end@@ -1626,7 +1626,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ title: "This is an updated topic title" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.not_to change { post.topic.bumped_at }end@@ -1636,7 +1636,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ category_id: Fabricate(:category).id },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.not_to change { post.topic.bumped_at }end@@ -1674,7 +1674,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.not_to change { post.topic.bumped_at }end@@ -1688,7 +1688,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.to change { post.topic.bumped_at }end@@ -1703,7 +1703,7 @@ describe PostRevisor dopost_revisor.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.to change { post.topic.bumped_at }end@@ -1716,7 +1716,7 @@ describe PostRevisor dopost_revisor_other.revise!(post.user,{ raw: "updated body" },- revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.seconds,+ revised_at: post.updated_at + SiteSetting.editing_grace_period + 1.second,)}.not_to change { post.topic.bumped_at }enddiff --git a/spec/lib/s3_inventory_spec.rb b/spec/lib/s3_inventory_spec.rbindex 593cd88f879..ee2d756667d 100644--- a/spec/lib/s3_inventory_spec.rb+++ b/spec/lib/s3_inventory_spec.rb@@ -59,7 +59,7 @@ RSpec.describe S3Inventory do)end- @upload_1 = Fabricate(:upload, etag: "ETag", updated_at: 1.days.ago)+ @upload_1 = Fabricate(:upload, etag: "ETag", updated_at: 1.day.ago)@upload_2 = Fabricate(:upload, etag: "ETag2", updated_at: Time.now)@no_etag = Fabricate(:upload, updated_at: 2.days.ago)@@ -228,7 +228,7 @@ RSpec.describe S3Inventory doFabricate(:upload, etag: row[S3Inventory::CSV_ETAG_INDEX], updated_at: 2.days.ago)end- upload = Fabricate(:upload, etag: "ETag", updated_at: 1.days.ago)+ upload = Fabricate(:upload, etag: "ETag", updated_at: 1.day.ago)Fabricate(:upload, etag: "ETag2", updated_at: Time.now)no_etag = Fabricate(:upload, updated_at: 2.days.ago)diff --git a/spec/lib/site_setting_extension_spec.rb b/spec/lib/site_setting_extension_spec.rbindex 9a9e23425a5..8210082ee81 100644--- a/spec/lib/site_setting_extension_spec.rb+++ b/spec/lib/site_setting_extension_spec.rb@@ -996,8 +996,8 @@ RSpec.describe SiteSettingExtension doenddescribe "themeable settings" do- fab!(:theme_1) { Fabricate(:theme) }- fab!(:theme_2) { Fabricate(:theme) }+ fab!(:theme_1, :theme)+ fab!(:theme_2, :theme)fab!(:tss_1) doFabricate(:theme_site_setting_with_service,diff --git a/spec/lib/statistics_spec.rb b/spec/lib/statistics_spec.rbindex 6c8fe74077f..9f64ee563ba 100644--- a/spec/lib/statistics_spec.rb+++ b/spec/lib/statistics_spec.rb@@ -32,10 +32,10 @@ RSpec.describe Statistics doApplicationRequest.increment!(:page_view_logged_in_browser)end- UserVisit.create!(user_id: users[0].id, visited_at: date - 50.minute)+ UserVisit.create!(user_id: users[0].id, visited_at: date - 50.minutes)UserVisit.create!(user_id: users[0].id, visited_at: date - 36.hours)- UserVisit.create!(user_id: users[1].id, visited_at: date - 2.day)+ UserVisit.create!(user_id: users[1].id, visited_at: date - 2.days)UserVisit.create!(user_id: users[0].id, visited_at: date - 4.days)UserVisit.create!(user_id: users[2].id, visited_at: date - 6.days)UserVisit.create!(user_id: users[3].id, visited_at: date - 3.days)diff --git a/spec/lib/topic_query_spec.rb b/spec/lib/topic_query_spec.rbindex 11d5ecbc8ff..7948f62c5a8 100644--- a/spec/lib/topic_query_spec.rb+++ b/spec/lib/topic_query_spec.rb@@ -141,7 +141,7 @@ RSpec.describe TopicQuery dopinned_globally: true,like_count: 1,)- _topic = Fabricate(:topic, created_at: 5.minute.ago, like_count: 100)+ _topic = Fabricate(:topic, created_at: 5.minutes.ago, like_count: 100)topic = Fabricate(:topic, created_at: 1.minute.ago, like_count: 100)# pinned topic is older so generally it would not hit the batch without@@ -221,21 +221,21 @@ RSpec.describe TopicQuery dopinned1 =Fabricate(:topic,- bumped_at: 3.hour.ago,- pinned_at: 1.hours.ago,+ bumped_at: 3.hours.ago,+ pinned_at: 1.hour.ago,pinned_until: 10.days.from_now,pinned_globally: true,)pinned2 =Fabricate(:topic,- bumped_at: 2.hour.ago,+ bumped_at: 2.hours.ago,pinned_at: 4.hours.ago,pinned_until: 10.days.from_now,pinned_globally: true,)- unpinned1 = Fabricate(:topic, bumped_at: 2.hour.ago)- unpinned2 = Fabricate(:topic, bumped_at: 3.hour.ago)+ unpinned1 = Fabricate(:topic, bumped_at: 2.hours.ago)+ unpinned2 = Fabricate(:topic, bumped_at: 3.hours.ago)topic_query = TopicQuery.new(user)results = topic_query.send(:default_results)@@ -252,20 +252,20 @@ RSpec.describe TopicQuery doFabricate(:topic,category: cat,- bumped_at: 3.hour.ago,- pinned_at: 1.hours.ago,+ bumped_at: 3.hours.ago,+ pinned_at: 1.hour.ago,pinned_until: 10.days.from_now,)pinned2 =Fabricate(:topic,category: cat,- bumped_at: 2.hour.ago,+ bumped_at: 2.hours.ago,pinned_at: 4.hours.ago,pinned_until: 10.days.from_now,)- unpinned1 = Fabricate(:topic, category: cat, bumped_at: 2.hour.ago)- unpinned2 = Fabricate(:topic, category: cat, bumped_at: 3.hour.ago)+ unpinned1 = Fabricate(:topic, category: cat, bumped_at: 2.hours.ago)+ unpinned2 = Fabricate(:topic, category: cat, bumped_at: 3.hours.ago)topic_query = TopicQuery.new(user)results = topic_query.send(:default_results)@@ -2275,7 +2275,7 @@ RSpec.describe TopicQuery dodescribe "with topic_query_create_list_topics modifier" dofab!(:topic1) { Fabricate(:topic, created_at: 3.days.ago, bumped_at: 1.hour.ago) }- fab!(:topic2) { Fabricate(:topic, created_at: 2.days.ago, bumped_at: 3.hour.ago) }+ fab!(:topic2) { Fabricate(:topic, created_at: 2.days.ago, bumped_at: 3.hours.ago) }it "allows changing" dooriginal_topic_query = TopicQuery.new(user)diff --git a/spec/lib/topics_bulk_action_spec.rb b/spec/lib/topics_bulk_action_spec.rbindex 49f9ec6450d..2d1e13bf8f9 100644--- a/spec/lib/topics_bulk_action_spec.rb+++ b/spec/lib/topics_bulk_action_spec.rb@@ -5,7 +5,7 @@ RSpec.describe TopicsBulkAction dofab!(:topic) { Fabricate(:topic, user: user) }describe "#dismiss_topics" do- fab!(:user) { Fabricate(:user, created_at: 1.days.ago, refresh_auto_groups: true) }+ fab!(:user) { Fabricate(:user, created_at: 1.day.ago, refresh_auto_groups: true) }fab!(:category)fab!(:topic2) { Fabricate(:topic, category: category, created_at: 60.minutes.ago) }fab!(:topic3) { Fabricate(:topic, category: category, created_at: 120.minutes.ago) }@@ -161,7 +161,7 @@ RSpec.describe TopicsBulkAction dofab!(:fist_post) { Fabricate(:post, topic: topic) }describe "option 'perform action silently'" do- fab!(:watcher) { Fabricate(:user) }+ fab!(:watcher, :user)fab!(:admin)before dodiff --git a/spec/lib/topics_filter_spec.rb b/spec/lib/topics_filter_spec.rbindex 3954fe9379b..d561eed9fe4 100644--- a/spec/lib/topics_filter_spec.rb+++ b/spec/lib/topics_filter_spec.rb@@ -195,8 +195,8 @@ RSpec.describe TopicsFilter doenddescribe "ordering by hot score" do- fab!(:t1) { Fabricate(:topic) }- fab!(:t2) { Fabricate(:topic) }+ fab!(:t1, :topic)+ fab!(:t2, :topic)before doTopicHotScore.create!(topic_id: t1.id, score: 2.0)@@ -244,7 +244,7 @@ RSpec.describe TopicsFilter doendfab!(:expired_pinned_topic) do- Fabricate(:topic, pinned_at: 2.hour.ago, pinned_until: 1.hour.ago)+ Fabricate(:topic, pinned_at: 2.hours.ago, pinned_until: 1.hour.ago)enddescribe "when query string is `in:pinned`" do@@ -270,7 +270,7 @@ RSpec.describe TopicsFilter doenddescribe "new / unread operators" do- fab!(:user_for_new_filters) { Fabricate(:user) }+ fab!(:user_for_new_filters, :user)let!(:new_topic) { Fabricate(:topic) }let!(:unread_topic) doFabricate(:topic, created_at: 2.days.ago).tap do |t|diff --git a/spec/models/about_spec.rb b/spec/models/about_spec.rbindex f756ad9932b..e9a805da876 100644--- a/spec/models/about_spec.rb+++ b/spec/models/about_spec.rb@@ -67,9 +67,9 @@ RSpec.describe About dodescribe "#category_moderators" dofab!(:user)fab!(:public_cat_moderator) { Fabricate(:user, last_seen_at: 1.month.ago) }- fab!(:private_cat_moderator) { Fabricate(:user, last_seen_at: 2.month.ago) }- fab!(:common_moderator) { Fabricate(:user, last_seen_at: 3.month.ago) }- fab!(:common_moderator_2) { Fabricate(:user, last_seen_at: 4.month.ago) }+ fab!(:private_cat_moderator) { Fabricate(:user, last_seen_at: 2.months.ago) }+ fab!(:common_moderator) { Fabricate(:user, last_seen_at: 3.months.ago) }+ fab!(:common_moderator_2) { Fabricate(:user, last_seen_at: 4.months.ago) }fab!(:public_group) doFabricate(:public_group, users: [public_cat_moderator, common_moderator, common_moderator_2])diff --git a/spec/models/api_key_spec.rb b/spec/models/api_key_spec.rbindex 8bf69c794e5..607ff488a9f 100644--- a/spec/models/api_key_spec.rb+++ b/spec/models/api_key_spec.rb@@ -94,7 +94,7 @@ RSpec.describe ApiKey doSiteSetting.revoke_api_keys_maxlife_days = 2older_key = Fabricate(:api_key, created_at: 3.days.ago)- newer_key = Fabricate(:api_key, created_at: 1.days.ago)+ newer_key = Fabricate(:api_key, created_at: 1.day.ago)revoked_key = Fabricate(:api_key, created_at: 3.days.ago, revoked_at: 1.day.ago)expect { ApiKey.revoke_max_life_keys! }.to change { older_key.reload.revoked_at }.from(nil).to(diff --git a/spec/models/category_list_spec.rb b/spec/models/category_list_spec.rbindex 6c5d2a3d8fa..68abc136ef5 100644--- a/spec/models/category_list_spec.rb+++ b/spec/models/category_list_spec.rb@@ -305,7 +305,7 @@ RSpec.describe CategoryList docat4 = Fabricate(:category_with_definition, position: 3)cat5 = Fabricate(:category_with_definition, parent_category_id: cat2.id)- Fabricate(:topic, category_id: cat3.id, bumped_at: 1.minutes.ago)+ Fabricate(:topic, category_id: cat3.id, bumped_at: 1.minute.ago)Fabricate(:topic, category_id: cat5.id, bumped_at: 2.minutes.ago)Fabricate(:topic, category_id: cat1.id, bumped_at: 3.minutes.ago)Fabricate(:topic, category_id: cat2.id, bumped_at: 5.minutes.ago)@@ -329,7 +329,7 @@ RSpec.describe CategoryList dosub_cat_private.set_permissions(admins: :full)sub_cat_private.save- Fabricate(:topic, category: sub_cat_private, bumped_at: 1.minutes.ago)+ Fabricate(:topic, category: sub_cat_private, bumped_at: 1.minute.ago)Fabricate(:topic, category: public_cat, bumped_at: 3.minutes.ago)Fabricate(:topic, category: public_cat2, bumped_at: 4.minutes.ago)diff --git a/spec/models/concerns/reports/associated_accounts_by_provider_spec.rb b/spec/models/concerns/reports/associated_accounts_by_provider_spec.rbindex 232684f73e7..e0903d39ced 100644--- a/spec/models/concerns/reports/associated_accounts_by_provider_spec.rb+++ b/spec/models/concerns/reports/associated_accounts_by_provider_spec.rb@@ -2,12 +2,12 @@RSpec.describe "Reports::AssociatedAccountsByProvider" dodescribe "associated_accounts_by_provider report" do- fab!(:user1) { Fabricate(:user) }- fab!(:user2) { Fabricate(:user) }- fab!(:user3) { Fabricate(:user) }- fab!(:user4) { Fabricate(:user) } # User with no associated accounts- fab!(:user5) { Fabricate(:user) } # User with disabled provider- fab!(:user6) { Fabricate(:user) } # User with DiscourseConnect+ fab!(:user1, :user)+ fab!(:user2, :user)+ fab!(:user3, :user)+ fab!(:user4, :user) # User with no associated accounts+ fab!(:user5, :user) # User with disabled provider+ fab!(:user6, :user) # User with DiscourseConnectbefore do# Mock enabled authenticators to only include specific providersdiff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rbindex 062d88c31ea..f665cb9e8a2 100644--- a/spec/models/group_spec.rb+++ b/spec/models/group_spec.rb@@ -92,7 +92,7 @@ RSpec.describe Group doit "filters results by datetime using the before parameter" dop1 = Fabricate(:post)- p2 = Fabricate(:post, created_at: p1.created_at + 2.minute)+ p2 = Fabricate(:post, created_at: p1.created_at + 2.minutes)group.add(p1.user)posts = group.posts_for(Guardian.new, before: p1.created_at + 1.minute)@@ -757,7 +757,7 @@ RSpec.describe Group doenddescribe "when a user has qualified for trust level 1" do- fab!(:user) { Fabricate(:user, trust_level: 1, created_at: Time.zone.now - 10.years) }+ fab!(:user) { Fabricate(:user, trust_level: 1, created_at: 10.years.ago) }fab!(:group) { Fabricate(:group, grant_trust_level: 3) }fab!(:group2) { Fabricate(:group, grant_trust_level: 2) }diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rbindex 90d1dc226ff..5c7b4be8ad4 100644--- a/spec/models/notification_spec.rb+++ b/spec/models/notification_spec.rb@@ -504,7 +504,7 @@ RSpec.describe Notification doendfab!(:unread_high_priority_2) do- create(high_priority: true, read: false, created_at: 1.minutes.ago)+ create(high_priority: true, read: false, created_at: 1.minute.ago)endfab!(:read_high_priority_2) docreate(high_priority: true, read: true, created_at: 2.minutes.ago)diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rbindex 1e550d1bf33..f0069caa842 100644--- a/spec/models/post_mover_spec.rb+++ b/spec/models/post_mover_spec.rb@@ -2055,7 +2055,7 @@ RSpec.describe PostMover doFabricate(:post, topic: source_2_topic, user: user, created_at: 2.hours.ago)create_post_timing(source_2_topic.first_post, user, 400)source_2_post =- Fabricate(:post, topic: source_2_topic, user: user, created_at: 1.hours.ago)+ Fabricate(:post, topic: source_2_topic, user: user, created_at: 1.hour.ago)create_post_timing(source_2_topic.posts.second, user, 500)moved_to =diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rbindex 72093344ad2..aa8e24cbe2e 100644--- a/spec/models/report_spec.rb+++ b/spec/models/report_spec.rb@@ -734,7 +734,7 @@ RSpec.describe Report doexporter = Jobs::ExportCsvFile.newexporter.entity = "report"- exporter.extra = HashWithIndifferentAccess.new(name: "flags_status")+ exporter.extra = ActiveSupport::HashWithIndifferentAccess.new(name: "flags_status")exporter.current_user = flaggerexported_csv = []exporter.report_export { |entry| exported_csv << entry }@@ -1882,35 +1882,35 @@ RSpec.describe Report dotopic: topic_1,anonymous_views: 4,logged_in_views: 2,- viewed_at: Time.zone.now - 5.days,+ viewed_at: 5.days.ago,)Fabricate(:topic_view_stat,topic: topic_1,anonymous_views: 5,logged_in_views: 18,- viewed_at: Time.zone.now - 3.days,+ viewed_at: 3.days.ago,)Fabricate(:topic_view_stat,topic: topic_2,anonymous_views: 14,logged_in_views: 21,- viewed_at: Time.zone.now - 5.days,+ viewed_at: 5.days.ago,)Fabricate(:topic_view_stat,topic: topic_2,anonymous_views: 9,logged_in_views: 13,- viewed_at: Time.zone.now - 1.days,+ viewed_at: 1.day.ago,)Fabricate(:topic_view_stat,topic: Fabricate(:topic),anonymous_views: 1,logged_in_views: 34,- viewed_at: Time.zone.now - 40.days,+ viewed_at: 40.days.ago,)enddiff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rbindex 7b463735dda..06a4861c2db 100644--- a/spec/models/site_setting_spec.rb+++ b/spec/models/site_setting_spec.rb@@ -98,7 +98,7 @@ RSpec.describe SiteSetting doendit "should_return_a_time_period" do- expect(SiteSetting.min_redirected_to_top_period(1.days.ago)).to eq(:daily)+ expect(SiteSetting.min_redirected_to_top_period(1.day.ago)).to eq(:daily)endend@@ -110,7 +110,7 @@ RSpec.describe SiteSetting doendit "should_return_a_time_period" do- expect(SiteSetting.min_redirected_to_top_period(1.days.ago)).to eq(nil)+ expect(SiteSetting.min_redirected_to_top_period(1.day.ago)).to eq(nil)endendenddiff --git a/spec/models/sitemap_spec.rb b/spec/models/sitemap_spec.rbindex fb12a377f61..9c831ab7015 100644--- a/spec/models/sitemap_spec.rb+++ b/spec/models/sitemap_spec.rb@@ -104,8 +104,8 @@ RSpec.describe Sitemap doendit "order topics by bumped_at asc" do- topic_1 = Fabricate(:topic, bumped_at: 3.minute.ago)- topic_2 = Fabricate(:topic, bumped_at: 1.minutes.ago)+ topic_1 = Fabricate(:topic, bumped_at: 3.minutes.ago)+ topic_2 = Fabricate(:topic, bumped_at: 1.minute.ago)topic_3 = Fabricate(:topic, bumped_at: 20.minutes.ago)topic_ids = sitemap.topics.map { |td| td[0] }diff --git a/spec/models/theme_site_setting_spec.rb b/spec/models/theme_site_setting_spec.rbindex 7a67bc990b9..c85ef1f2570 100644--- a/spec/models/theme_site_setting_spec.rb+++ b/spec/models/theme_site_setting_spec.rb@@ -1,8 +1,8 @@# frozen_string_literal: trueRSpec.describe ThemeSiteSetting do- fab!(:theme_1) { Fabricate(:theme) }- fab!(:theme_2) { Fabricate(:theme) }+ fab!(:theme_1, :theme)+ fab!(:theme_2, :theme)fab!(:theme_site_setting_1) doFabricate(:theme_site_setting_with_service,diff --git a/spec/models/topic_hot_scores_spec.rb b/spec/models/topic_hot_scores_spec.rbindex 936e337e87e..dc1207d0a91 100644--- a/spec/models/topic_hot_scores_spec.rb+++ b/spec/models/topic_hot_scores_spec.rb@@ -13,7 +13,7 @@ RSpec.describe TopicHotScore do# this will come in with a scoretopic = Fabricate(:topic, created_at: 1.hour.ago, bumped_at: 2.minutes.ago)- post = Fabricate(:post, topic: topic, created_at: 2.minute.ago)+ post = Fabricate(:post, topic: topic, created_at: 2.minutes.ago)PostActionCreator.like(user, post)TopicHotScore.update_scoresdiff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex 90b4af19c68..ff834f0fead 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -3542,7 +3542,7 @@ describe Topic dofrom_address: "[email protected]",topic: topic,post: topic.posts.first,- created_at: 1.minutes.ago,+ created_at: 1.minute.ago,)enddiff --git a/spec/models/topic_timer_spec.rb b/spec/models/topic_timer_spec.rbindex 8acc5685c04..e67b28703e8 100644--- a/spec/models/topic_timer_spec.rb+++ b/spec/models/topic_timer_spec.rb@@ -56,7 +56,7 @@ RSpec.describe TopicTimer, type: :model dotopic_timer =Fabricate.build(:topic_timer,- execute_at: Time.zone.now + 1.hour,+ execute_at: 1.hour.from_now,user: Fabricate(:user),topic: Fabricate(:topic),)@@ -70,7 +70,7 @@ RSpec.describe TopicTimer, type: :model dotopic_timer =Fabricate.build(:topic_timer,- execute_at: Time.zone.now - 1.hour,+ execute_at: 1.hour.ago,created_at: Time.zone.now,user: Fabricate(:user),topic: Fabricate(:topic),@@ -180,7 +180,7 @@ RSpec.describe TopicTimer, type: :model dotopic_timer =Fabricate.build(:topic_timer,- execute_at: Time.zone.now + 1.hour,+ execute_at: 1.hour.from_now,user: Fabricate(:user),topic: Fabricate(:topic),)@@ -192,8 +192,8 @@ RSpec.describe TopicTimer, type: :model dotopic_timer =Fabricate.create(:topic_timer,- execute_at: Time.zone.now - 1.hour,- created_at: Time.zone.now - 2.hour,+ execute_at: 1.hour.ago,+ created_at: 2.hours.ago,user: Fabricate(:user),topic: Fabricate(:topic),)@@ -206,8 +206,8 @@ RSpec.describe TopicTimer, type: :model dotopic_timer =Fabricate.build(:topic_timer,- execute_at: Time.zone.now - 1.hour,- created_at: Time.zone.now - 2.hour,+ execute_at: 1.hour.ago,+ created_at: 2.hours.ago,user: Fabricate(:user),topic: Fabricate(:topic),)diff --git a/spec/models/trust_level3_requirements_spec.rb b/spec/models/trust_level3_requirements_spec.rbindex ddff5b73f0a..57be45c8e82 100644--- a/spec/models/trust_level3_requirements_spec.rb+++ b/spec/models/trust_level3_requirements_spec.rb@@ -101,7 +101,7 @@ RSpec.describe TrustLevel3Requirements doit "does not return if the user been silenced or suspended over 6 months ago" dofreeze_time 1.year.ago do- UserSilencer.new(user, moderator, silenced_till: 1.months.from_now).silence+ UserSilencer.new(user, moderator, silenced_till: 1.month.from_now).silenceUserHistory.create!(target_user_id: user.id, action: UserHistory.actions[:suspend_user])end@@ -111,7 +111,7 @@ RSpec.describe TrustLevel3Requirements dofreeze_time 3.months.ago doUserSilencer.new(user).unsilence- UserSilencer.new(user, moderator, silenced_till: 1.months.from_now).silence+ UserSilencer.new(user, moderator, silenced_till: 1.month.from_now).silenceUserHistory.create!(target_user_id: user.id, action: UserHistory.actions[:suspend_user])enddiff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 386a34b327b..606d75ee058 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -1583,7 +1583,7 @@ RSpec.describe User doit "is false if first post was more than 24 hours ago" dou = create_test_user(created_at: 28.hours.ago)- u.user_stat.update!(first_post_created_at: 25.hour.ago)+ u.user_stat.update!(first_post_created_at: 25.hours.ago)expect(u.new_user_posting_on_first_day?).to eq(false)endend@@ -3289,12 +3289,7 @@ RSpec.describe User doendit "is false when no dnd timing is present for the current time" do- Fabricate(- :do_not_disturb_timing,- user: user,- starts_at: Time.zone.now - 2.day,- ends_at: 1.minute.ago,- )+ Fabricate(:do_not_disturb_timing, user:, starts_at: 2.days.ago, ends_at: 1.minute.ago)expect(user.do_not_disturb?).to eq(false)endend@@ -3318,7 +3313,7 @@ RSpec.describe User doit "excludes invites redeemed after user creation" doinvite = Fabricate(:invite, invited_by: Fabricate(:user))- Fabricate(:invited_user, invite: invite, user: user, redeemed_at: user.created_at + 6.second)+ Fabricate(:invited_user, invite: invite, user:, redeemed_at: user.created_at + 6.seconds)expect(user.invited_by).to eq(nil)enddiff --git a/spec/models/user_stat_spec.rb b/spec/models/user_stat_spec.rbindex b63f632d468..58a5ce7732a 100644--- a/spec/models/user_stat_spec.rb+++ b/spec/models/user_stat_spec.rb@@ -160,14 +160,14 @@ RSpec.describe UserStat doend# User affected- expect(user.user_stat.reload.first_unread_pm_at).to be_within(1.seconds).of(+ expect(user.user_stat.reload.first_unread_pm_at).to be_within(1.second).of(pm_topic.reload.updated_at,)- expect(user_2.user_stat.reload.first_unread_pm_at).to be_within(1.seconds).of(+ expect(user_2.user_stat.reload.first_unread_pm_at).to be_within(1.second).of(UserStat::UPDATE_UNREAD_MINUTES_AGO.minutes.ago,)expect(user_3.user_stat.reload.first_unread_pm_at).to eq_time(user_3_orig_first_unread_pm_at)- expect(user_4.user_stat.reload.first_unread_pm_at).to be_within(1.seconds).of(+ expect(user_4.user_stat.reload.first_unread_pm_at).to be_within(1.second).of(UserStat::UPDATE_UNREAD_MINUTES_AGO.minutes.ago,)expect(user_5.user_stat.reload.first_unread_pm_at).to eq_time(pm_topic_2.reload.updated_at)diff --git a/spec/models/web_hook_events_daily_aggregate_spec.rb b/spec/models/web_hook_events_daily_aggregate_spec.rbindex 92dc9af653f..d9913882c37 100644--- a/spec/models/web_hook_events_daily_aggregate_spec.rb+++ b/spec/models/web_hook_events_daily_aggregate_spec.rb@@ -7,7 +7,7 @@ RSpec.describe WebHookEventsDailyAggregate do:web_hook_event,status: 200,web_hook: web_hook,- created_at: 1.days.ago,+ created_at: 1.day.ago,duration: 280,)end@@ -17,7 +17,7 @@ RSpec.describe WebHookEventsDailyAggregate doFabricate(:web_hook_event,status: 400,- created_at: 1.days.ago,+ created_at: 1.day.ago,web_hook: web_hook,duration: 200,)@@ -28,7 +28,7 @@ RSpec.describe WebHookEventsDailyAggregate do:web_hook_event,status: 400,web_hook: web_hook,- created_at: 1.days.ago,+ created_at: 1.day.ago,duration: 200,)end@@ -40,11 +40,11 @@ RSpec.describe WebHookEventsDailyAggregate doit "should be able to purge old web hook event aggregates" doweb_hook = Fabricate(:web_hook)- WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 1.days.ago, duration: 180)+ WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 1.day.ago, duration: 180)WebHookEvent.create!(status: 200, web_hook: web_hook, created_at: 2.days.ago, duration: 180)yesterday_aggregate =- WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.days.ago)+ WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.day.ago)WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id,@@ -61,12 +61,12 @@ RSpec.describe WebHookEventsDailyAggregate dodescribe "aggregation works" doit "should be able to aggregate web hook events" doyesterday_aggregate =- WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.days.ago)+ WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.day.ago)yesterday_events = [event, failed_event, failed_event2]expect(WebHookEventsDailyAggregate.count).to eq(1)expect(yesterday_aggregate.web_hook_id).to eq(web_hook.id)- expect(yesterday_aggregate.date).to eq(1.days.ago.to_date)+ expect(yesterday_aggregate.date).to eq(1.day.ago.to_date)expect(yesterday_aggregate.mean_duration).to eq(yesterday_events.sum(&:duration) / yesterday_events.count,@@ -76,22 +76,22 @@ RSpec.describe WebHookEventsDailyAggregate doendit "should be able to filter by day" do- WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.days.ago)+ WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 1.day.ago)WebHookEventsDailyAggregate.create!(web_hook_id: web_hook.id, date: 0.days.ago)yesterday_events = [event, failed_event, failed_event2]today_events = [event_today, failed_event_today]- yesterday_aggregate = WebHookEventsDailyAggregate.by_day(1.days.ago, 1.days.ago)+ yesterday_aggregate = WebHookEventsDailyAggregate.by_day(1.day.ago, 1.day.ago)expect(yesterday_aggregate.count).to eq(1)- expect(yesterday_aggregate.first.date).to eq(1.days.ago.to_date)+ expect(yesterday_aggregate.first.date).to eq(1.day.ago.to_date)expect(WebHookEventsDailyAggregate.count).to eq(2)- today_and_yesterday_aggregate = WebHookEventsDailyAggregate.by_day(1.days.ago, 0.days.ago)+ today_and_yesterday_aggregate = WebHookEventsDailyAggregate.by_day(1.day.ago, 0.days.ago)expect(today_and_yesterday_aggregate.count).to eq(2)expect(today_and_yesterday_aggregate.map(&:date)).to eq(- [0.days.ago.to_date, 1.days.ago.to_date],+ [0.days.ago.to_date, 1.day.ago.to_date],)expect(today_and_yesterday_aggregate.map(&:mean_duration)).to eq([@@ -102,11 +102,11 @@ RSpec.describe WebHookEventsDailyAggregate doendit "should not create a new WebHookEventsDailyAggregate row if AggregateWebHooksEvents runs twice" do- expect { Jobs::AggregateWebHooksEvents.new.execute(date: 1.days.ago) }.to change {+ expect { Jobs::AggregateWebHooksEvents.new.execute(date: 1.day.ago) }.to change {WebHookEventsDailyAggregate.count}.by(1)- expect { Jobs::AggregateWebHooksEvents.new.execute(date: 1.days.ago) }.not_to change {+ expect { Jobs::AggregateWebHooksEvents.new.execute(date: 1.day.ago) }.not_to change {WebHookEventsDailyAggregate.count}enddiff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rbindex 42c7311ccc3..1ad3ee7ff1d 100644--- a/spec/requests/admin/dashboard_controller_spec.rb+++ b/spec/requests/admin/dashboard_controller_spec.rb@@ -17,14 +17,14 @@ RSpec.describe Admin::DashboardController do"emoji" => "🤾","title" => "Cool Beans","description" => "Now beans are included",- "created_at" => date1 || (Time.zone.now - 40.minutes),+ "created_at" => date1 || 40.minutes.ago,},{"id" => "2","emoji" => "🙈","title" => "Fancy Legumes","description" => "Legumes too!",- "created_at" => date2 || (Time.zone.now - 20.minutes),+ "created_at" => date2 || 20.minutes.ago,},]diff --git a/spec/requests/admin/staff_action_logs_controller_spec.rb b/spec/requests/admin/staff_action_logs_controller_spec.rbindex 9245aed55f8..06d0ea97096 100644--- a/spec/requests/admin/staff_action_logs_controller_spec.rb+++ b/spec/requests/admin/staff_action_logs_controller_spec.rb@@ -54,7 +54,7 @@ RSpec.describe Admin::StaffActionLogsController doendit "filter logs by end_date" do- get "/admin/logs/staff_action_logs.json", params: { end_date: 1.days.ago.iso8601 }+ get "/admin/logs/staff_action_logs.json", params: { end_date: 1.day.ago.iso8601 }json = response.parsed_bodyexpect(response.status).to eq(200)@@ -68,7 +68,7 @@ RSpec.describe Admin::StaffActionLogsController doget "/admin/logs/staff_action_logs.json",params: {start_date: 3.days.ago.iso8601,- end_date: 1.days.ago.iso8601,+ end_date: 1.day.ago.iso8601,}json = response.parsed_bodydiff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rbindex 865c62da152..a713b21b36e 100644--- a/spec/requests/admin/users_controller_spec.rb+++ b/spec/requests/admin/users_controller_spec.rb@@ -2626,7 +2626,7 @@ RSpec.describe Admin::UsersController doprovider_name: "github",provider_uid: "123456789",user_id: user.id,- last_used: 1.seconds.ago,+ last_used: 1.second.ago,)enddiff --git a/spec/requests/api/topics_spec.rb b/spec/requests/api/topics_spec.rbindex 141a9f15b4a..d5f7df8c76a 100644--- a/spec/requests/api/topics_spec.rb+++ b/spec/requests/api/topics_spec.rb@@ -1040,7 +1040,7 @@ RSpec.describe "topics" do},}- let(:request_body) { { time: Time.current + 1.day, status_type: "close" } }+ let(:request_body) { { time: 1.day.from_now, status_type: "close" } }let!(:topic_post) { Fabricate(:post) }let(:id) { topic_post.topic.id }diff --git a/spec/requests/bookmarks_controller_spec.rb b/spec/requests/bookmarks_controller_spec.rbindex 90e0b0dfaee..20dd6a09093 100644--- a/spec/requests/bookmarks_controller_spec.rb+++ b/spec/requests/bookmarks_controller_spec.rb@@ -19,7 +19,7 @@ RSpec.describe BookmarksController doparams: {bookmarkable_id: bookmark_post.id,bookmarkable_type: "Post",- reminder_at: (Time.zone.now + 1.day).iso8601,+ reminder_at: 1.day.from_now.iso8601,}expect(response.status).to eq(200)@@ -40,7 +40,7 @@ RSpec.describe BookmarksController doparams: {bookmarkable_id: bookmark_post.id,bookmarkable_type: "Post",- reminder_at: (Time.zone.now + 1.day).iso8601,+ reminder_at: 1.day.from_now.iso8601,}post "/bookmarks.json",params: {@@ -71,7 +71,7 @@ RSpec.describe BookmarksController doparams: {bookmarkable_id: bookmark_post.id,bookmarkable_type: "Post",- reminder_at: (Time.zone.now + 1.day).iso8601,+ reminder_at: 1.day.from_now.iso8601,}expect(response.status).to eq(400)@@ -83,7 +83,7 @@ RSpec.describe BookmarksController doparams: {bookmarkable_id: bookmark_topic.id,bookmarkable_type: "Topic",- reminder_at: (Time.zone.now + 1.day).iso8601,+ reminder_at: 1.day.from_now.iso8601,}expect(response.status).to eq(400)diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rbindex 4d9f1af452a..072869313d1 100644--- a/spec/requests/groups_controller_spec.rb+++ b/spec/requests/groups_controller_spec.rb@@ -1406,21 +1406,11 @@ RSpec.describe GroupsController dodescribe "#members" dolet(:user1) do- Fabricate(- :user,- last_seen_at: Time.zone.now,- last_posted_at: Time.zone.now - 1.day,- email: "[email protected]",- )+ Fabricate(:user, last_seen_at: Time.zone.now, last_posted_at: 1.day.ago, email: "[email protected]")endlet(:user2) do- Fabricate(- :user,- last_seen_at: Time.zone.now - 1.day,- last_posted_at: Time.zone.now,- email: "[email protected]",- )+ Fabricate(:user, last_seen_at: 1.day.ago, last_posted_at: Time.zone.now, email: "[email protected]")endfab!(:user3) { Fabricate(:user, last_seen_at: nil, last_posted_at: nil, email: "[email protected]") }@@ -2540,7 +2530,7 @@ RSpec.describe GroupsController doit "should create the right PM" doowner1 = Fabricate(:user, last_seen_at: Time.zone.now)- owner2 = Fabricate(:user, last_seen_at: Time.zone.now - 1.day)+ owner2 = Fabricate(:user, last_seen_at: 1.day.ago)[owner1, owner2].each { |owner| group.add_owner(owner) }sign_in(user)diff --git a/spec/requests/reviewables_controller_spec.rb b/spec/requests/reviewables_controller_spec.rbindex 28b22de9df1..ebdd49d607e 100644--- a/spec/requests/reviewables_controller_spec.rb+++ b/spec/requests/reviewables_controller_spec.rb@@ -329,7 +329,7 @@ RSpec.describe ReviewablesController doendit "returns reviewable content that matches the date range" do- reviewable = Fabricate(:reviewable, created_at: 2.day.ago)+ reviewable = Fabricate(:reviewable, created_at: 2.days.ago)get "/review.json?from_date=#{from}&to_date=#{to}"diff --git a/spec/requests/sitemap_controller_spec.rb b/spec/requests/sitemap_controller_spec.rbindex 0a1d62771ec..b622be98581 100644--- a/spec/requests/sitemap_controller_spec.rb+++ b/spec/requests/sitemap_controller_spec.rb@@ -98,18 +98,18 @@ RSpec.describe SitemapController dopage_size = TopicView.chunk_sizeincomplete_page_size = TopicView.chunk_size - 1- topic.update!(posts_count: incomplete_page_size, updated_at: 4.hour.ago)+ topic.update!(posts_count: incomplete_page_size, updated_at: 4.hours.ago)get "/sitemap_recent.xml"url = Nokogiri::XML::Document.parse(response.body).at_css("loc").textexpect(url).not_to include("?page=2")- topic.update!(posts_count: page_size, updated_at: 3.hour.ago)+ topic.update!(posts_count: page_size, updated_at: 3.hours.ago)get "/sitemap_recent.xml"url = Nokogiri::XML::Document.parse(response.body).at_css("loc").textexpect(url).not_to include("?page=2")two_page_size = page_size + 1- topic.update!(posts_count: two_page_size, updated_at: 2.hour.ago)+ topic.update!(posts_count: two_page_size, updated_at: 2.hours.ago)get "/sitemap_recent.xml"url = Nokogiri::XML::Document.parse(response.body).at_css("loc").textexpect(url).to include("?page=2")diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rbindex 93237d9b8b7..3f302020598 100644--- a/spec/requests/static_controller_spec.rb+++ b/spec/requests/static_controller_spec.rb@@ -70,7 +70,7 @@ RSpec.describe StaticController doit "can serve assets" dobegin- assets_path = Rails.root.join("public/assets")+ assets_path = Rails.public_path.join("assets")FileUtils.mkdir_p(assets_path)diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex f8216b6fa16..d1900b0f3ff 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -4935,7 +4935,7 @@ RSpec.describe TopicsController dopost "/t/#{topic.id}/timer.json",params: {- time: Time.current - 1.day,+ time: 1.day.ago,status_type: TopicTimer.types[1],}expect(response.status).to eq(400)diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rbindex 3346b6156ac..3078eafb2b9 100644--- a/spec/requests/users_controller_spec.rb+++ b/spec/requests/users_controller_spec.rb@@ -250,7 +250,7 @@ RSpec.describe UsersController doendit "fails without a server session" do- user.update!(created_at: Time.zone.now - 8.minutes)+ user.update!(created_at: 8.minutes.ago)put "/u/#{user.username}/remove-password.json"expect(response.status).to eq(403)end@@ -262,7 +262,7 @@ RSpec.describe UsersController doendit "succeeds with a newly-created user" do- user.update!(created_at: Time.zone.now - 1.minute)+ user.update!(created_at: 1.minute.ago)put "/u/#{user.username}/remove-password.json"expect(response.status).to eq(200)end@@ -293,7 +293,7 @@ RSpec.describe UsersController doendit "fails without a server session" do- user.update!(created_at: Time.zone.now - 8.minutes)+ user.update!(created_at: 8.minutes.ago)put "/u/#{user.username}/remove-password.json" #expect(response.status).to eq(403)end@@ -6904,7 +6904,7 @@ RSpec.describe UsersController doendit "returns unconfirmed session response when user was created more than N minutes ago" do- user1.created_at = Time.zone.now - 10.minutes+ user1.created_at = 10.minutes.agouser1.save!(validate: false)post "/u/second_factors.json"@@ -6915,7 +6915,7 @@ RSpec.describe UsersController doendit "returns empty list for a recently created user" do- user1.created_at = Time.zone.now - 1.minutes+ user1.created_at = 1.minute.agouser1.save!(validate: false)post "/u/second_factors.json"@@ -7819,7 +7819,7 @@ RSpec.describe UsersController doread: true,user: user,notification_type: Notification.types[:group_message_summary],- created_at: 1.minutes.ago,+ created_at: 1.minute.ago,)end@@ -7915,7 +7915,7 @@ RSpec.describe UsersController doendit "responds with an array of personal messages and user watching group messages that are not associated with any of the unread private_message notifications" do- group_message1.update!(bumped_at: 1.minutes.ago)+ group_message1.update!(bumped_at: 1.minute.ago)message_without_notification.update!(bumped_at: 3.minutes.ago)group_message2.update!(bumped_at: 6.minutes.ago)message_with_read_notification.update!(bumped_at: 10.minutes.ago)diff --git a/spec/serializers/basic_user_serializer_spec.rb b/spec/serializers/basic_user_serializer_spec.rbindex aeb0564cae0..8de8c01b048 100644--- a/spec/serializers/basic_user_serializer_spec.rb+++ b/spec/serializers/basic_user_serializer_spec.rb@@ -56,7 +56,7 @@ RSpec.describe BasicUserSerializer doendit "doesn't add expired user status" do- user.user_status.ends_at = 1.minutes.ago+ user.user_status.ends_at = 1.minute.agojson = serializer.as_jsonexpect(json.keys).not_to include :statusenddiff --git a/spec/serializers/current_user_serializer_spec.rb b/spec/serializers/current_user_serializer_spec.rbindex c34fc1bf909..490134f4783 100644--- a/spec/serializers/current_user_serializer_spec.rb+++ b/spec/serializers/current_user_serializer_spec.rb@@ -207,7 +207,7 @@ RSpec.describe CurrentUserSerializer doit "doesn't add expired user status" doSiteSetting.enable_user_status = true- user.user_status.ends_at = 1.minutes.ago+ user.user_status.ends_at = 1.minute.agoserializer = described_class.new(user, scope: Guardian.new(user), root: false)json = serializer.as_jsondiff --git a/spec/serializers/found_user_serializer_spec.rb b/spec/serializers/found_user_serializer_spec.rbindex 655c9bd1668..36965f8ea77 100644--- a/spec/serializers/found_user_serializer_spec.rb+++ b/spec/serializers/found_user_serializer_spec.rb@@ -54,7 +54,7 @@ RSpec.describe FoundUserSerializer doendit "doesn't add expired user status" do- user.user_status.ends_at = 1.minutes.ago+ user.user_status.ends_at = 1.minute.agoserializer = described_class.new(user, scope: Guardian.new(user), root: false)json = serializer.as_jsondiff --git a/spec/serializers/group_user_serializer_spec.rb b/spec/serializers/group_user_serializer_spec.rbindex 3f80a3f7da3..0132a14e732 100644--- a/spec/serializers/group_user_serializer_spec.rb+++ b/spec/serializers/group_user_serializer_spec.rb@@ -27,7 +27,7 @@ RSpec.describe GroupUserSerializer doit "doesn't add expired user status" doSiteSetting.enable_user_status = true- user.user_status.ends_at = 1.minutes.ago+ user.user_status.ends_at = 1.minute.agoserializer = described_class.new(user, scope: Guardian.new(user), root: false)json = serializer.as_jsondiff --git a/spec/serializers/user_card_serializer_spec.rb b/spec/serializers/user_card_serializer_spec.rbindex 3bd7fa90e18..b039d1ac465 100644--- a/spec/serializers/user_card_serializer_spec.rb+++ b/spec/serializers/user_card_serializer_spec.rb@@ -109,7 +109,7 @@ RSpec.describe UserCardSerializer doit "doesn't add expired user status" doSiteSetting.enable_user_status = true- user.user_status.ends_at = 1.minutes.ago+ user.user_status.ends_at = 1.minute.agoserializer = described_class.new(user, scope: Guardian.new(user), root: false)json = serializer.as_jsondiff --git a/spec/serializers/user_serializer_spec.rb b/spec/serializers/user_serializer_spec.rbindex 79b1b49c864..3037362db4a 100644--- a/spec/serializers/user_serializer_spec.rb+++ b/spec/serializers/user_serializer_spec.rb@@ -438,7 +438,7 @@ RSpec.describe UserSerializer dorevoked_at: Time.zone.now,)user_api_key_1 = Fabricate(:readonly_user_api_key, user: user, last_used_at: 7.days.ago)- user_api_key_2 = Fabricate(:readonly_user_api_key, user: user, last_used_at: 1.days.ago)+ user_api_key_2 = Fabricate(:readonly_user_api_key, user: user, last_used_at: 1.day.ago)user_api_key_3 =Fabricate(:readonly_user_api_key,diff --git a/spec/services/discourse_id/register_spec.rb b/spec/services/discourse_id/register_spec.rbindex 1d03a2e5e91..df8066cefe0 100644--- a/spec/services/discourse_id/register_spec.rb+++ b/spec/services/discourse_id/register_spec.rb@@ -10,8 +10,8 @@ RSpec.describe DiscourseId::Register dolet(:client_secret) { "test_client_secret" }let(:discourse_id_url) { "https://id.discourse.com" }- fab!(:logo_upload) { Fabricate(:upload) }- fab!(:logo_small_upload) { Fabricate(:upload) }+ fab!(:logo_upload, :upload)+ fab!(:logo_small_upload, :upload)before doSiteSetting.discourse_id_provider_url = discourse_id_urldiff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rbindex 1c8d29490d7..beb279402c7 100644--- a/spec/services/post_alerter_spec.rb+++ b/spec/services/post_alerter_spec.rb@@ -1379,7 +1379,7 @@ RSpec.describe PostAlerter doevil_trout.update!(last_seen_at: 5.minutes.ago)expect { mention_post }.to change { Jobs::PushNotification.jobs.count }- expect(Jobs::PushNotification.jobs[0]["at"]).to be_within(30.second).of(+ expect(Jobs::PushNotification.jobs[0]["at"]).to be_within(30.seconds).of(5.minutes.from_now.to_f,)end@@ -1406,7 +1406,7 @@ RSpec.describe PostAlerter dodelay = 5.minutes.from_now.to_fexpect { mention_post }.to change { Jobs::SendPushNotification.jobs.count }- expect(Jobs::SendPushNotification.jobs[0]["at"]).to be_within(30.second).of(delay)+ expect(Jobs::SendPushNotification.jobs[0]["at"]).to be_within(30.seconds).of(delay)endit "does not delay push notification for inactive offline user" dodiff --git a/spec/services/topic_status_updater_spec.rb b/spec/services/topic_status_updater_spec.rbindex b1f5cf3f9d9..0a8cb906260 100644--- a/spec/services/topic_status_updater_spec.rb+++ b/spec/services/topic_status_updater_spec.rb@@ -146,7 +146,7 @@ RSpec.describe TopicStatusUpdater dotimer = TopicTimer.find_by(topic: topic)expect(timer).not_to eq(nil)expect(timer.duration_minutes).to eq(72 * 60)- expect(timer.execute_at).to be_within_one_second_of(Time.zone.now + 72.hours)+ expect(timer.execute_at).to be_within_one_second_of(72.hours.from_now)endendenddiff --git a/spec/services/topic_timestamp_changer_spec.rb b/spec/services/topic_timestamp_changer_spec.rbindex 45c41cb7bee..dbde22d5ff8 100644--- a/spec/services/topic_timestamp_changer_spec.rb+++ b/spec/services/topic_timestamp_changer_spec.rb@@ -8,7 +8,7 @@ RSpec.describe TopicTimestampChanger dolet!(:p2) { Fabricate(:post, topic: topic, created_at: old_timestamp + 1.day) }context "when new timestamp is in the future" do- let(:new_timestamp) { old_timestamp + 2.day }+ let(:new_timestamp) { old_timestamp + 2.days }it "should raise the right error" doexpect {@@ -18,7 +18,7 @@ RSpec.describe TopicTimestampChanger doendcontext "when new timestamp is in the past" do- let(:new_timestamp) { old_timestamp - 2.day }+ let(:new_timestamp) { old_timestamp - 2.days }it "changes the timestamp of the topic and opening post" dofreeze_timediff --git a/spec/system/about_page_spec.rb b/spec/system/about_page_spec.rbindex eb47ce8508f..fdc6dd0fceb 100644--- a/spec/system/about_page_spec.rb+++ b/spec/system/about_page_spec.rb@@ -199,7 +199,7 @@ describe "About page", type: :system doit "displays only the 6 most recently seen admins when there are more than 6 admins" doadmins[0].update!(last_seen_at: 4.minutes.ago)- admins[1].update!(last_seen_at: 1.minutes.ago)+ admins[1].update!(last_seen_at: 1.minute.ago)admins[2].update!(last_seen_at: 10.minutes.ago)about_page.visitdiff --git a/spec/system/admin_config_theme_site_settings_spec.rb b/spec/system/admin_config_theme_site_settings_spec.rbindex c54a9e0c49a..afd83d8201c 100644--- a/spec/system/admin_config_theme_site_settings_spec.rb+++ b/spec/system/admin_config_theme_site_settings_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: truedescribe "Admin Theme Site Settings", type: :system do- fab!(:current_user) { Fabricate(:admin) }+ fab!(:current_user, :admin)fab!(:theme_1) { Fabricate(:theme, name: "Blue Steel") }fab!(:theme_2) { Fabricate(:theme, name: "Derelicte") }fab!(:theme_site_setting_1) dodiff --git a/spec/system/category_localizations_spec.rb b/spec/system/category_localizations_spec.rbindex c0b7308e494..f1f7b087976 100644--- a/spec/system/category_localizations_spec.rb+++ b/spec/system/category_localizations_spec.rb@@ -67,7 +67,7 @@ describe "Category Localizations", type: :system doenddescribe "when editing a category with no category localizations" do- fab!(:mono_category) { Fabricate(:category) }+ fab!(:mono_category, :category)it "should show info hint to add new localizations" docategory_page.visit_edit_localizations(mono_category)diff --git a/spec/system/create_invite_spec.rb b/spec/system/create_invite_spec.rbindex ddb9b7d0d1e..1aefc519616 100644--- a/spec/system/create_invite_spec.rb+++ b/spec/system/create_invite_spec.rb@@ -55,7 +55,7 @@ describe "Creating Invites", type: :system domax_redemption_count: 7,)expect(user_invited_pending_page.latest_invite.expiry_date).to be_within(2.minutes).of(- Time.zone.now + 3.days,+ 3.days.from_now,)end@@ -167,7 +167,7 @@ describe "Creating Invites", type: :system doexpect(user_invited_pending_page.latest_invite).to have_group(another_group)expect(user_invited_pending_page.latest_invite).to have_topic(topic)expect(user_invited_pending_page.latest_invite.expiry_date).to be_within(2.minutes).of(- Time.zone.now + 1.day,+ 1.day.from_now,)sent_email = ActionMailer::Base.deliveries.firstexpect(sent_email.to).to contain_exactly("[email protected]")diff --git a/spec/system/search_spec.rb b/spec/system/search_spec.rbindex 20e0f3c7ed2..01983896420 100644--- a/spec/system/search_spec.rb+++ b/spec/system/search_spec.rb@@ -269,7 +269,7 @@ describe "Search", type: :system dodescribe "Private Message Icon in Search Results" dofab!(:user)- fab!(:other_user) { Fabricate(:user) }+ fab!(:other_user, :user)fab!(:pm_topic) doFabricate(:private_message_topic,