A platform for community discussion. Free, open, simple.
DEV: Revert rails 7.1 upgrade (#27522)
Jarek Radosz5cb84f8dcf4e
diff --git a/.licensed.yml b/.licensed.ymlindex 314a5e82ac4..c5903c31e0c 100644--- a/.licensed.yml+++ b/.licensed.yml@@ -31,10 +31,6 @@ ignored:- timeout # Ruby (default gem)- uri # Ruby (default gem)- mutex_m # BSD-2-Clause- - irb # Ruby (default gem)- - rdoc # Ruby (default gem)- - reline # Ruby (default gem)- - stringio # Ruby (default gem)reviewed:bundler:diff --git a/Gemfile b/Gemfileindex ad2429502ff..b053716bfcd 100644--- a/Gemfile+++ b/Gemfile@@ -6,13 +6,13 @@ source "https://rubygems.org"gem "bootsnap", require: false, platform: :mri-gem "actionmailer", "~> 7.1.0"-gem "actionpack", "~> 7.1.0"-gem "actionview", "~> 7.1.0"-gem "activemodel", "~> 7.1.0"-gem "activerecord", "~> 7.1.0"-gem "activesupport", "~> 7.1.0"-gem "railties", "~> 7.1.0"+gem "actionmailer", "< 7.1"+gem "actionpack", "< 7.1"+gem "actionview", "< 7.1"+gem "activemodel", "< 7.1"+gem "activerecord", "< 7.1"+gem "activesupport", "< 7.1"+gem "railties", "< 7.1"gem "sprockets-rails"gem "json"diff --git a/Gemfile.lock b/Gemfile.lockindex fde78e903f9..983f0ad4338 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -1,54 +1,45 @@GEMremote: https://rubygems.org/specs:- actionmailer (7.1.3.4)- actionpack (= 7.1.3.4)- actionview (= 7.1.3.4)- activejob (= 7.1.3.4)- activesupport (= 7.1.3.4)+ actionmailer (7.0.8.4)+ actionpack (= 7.0.8.4)+ actionview (= 7.0.8.4)+ activejob (= 7.0.8.4)+ activesupport (= 7.0.8.4)mail (~> 2.5, >= 2.5.4)net-imapnet-popnet-smtp- rails-dom-testing (~> 2.2)- actionpack (7.1.3.4)- actionview (= 7.1.3.4)- activesupport (= 7.1.3.4)- nokogiri (>= 1.8.5)- racc- rack (>= 2.2.4)- rack-session (>= 1.0.1)+ rails-dom-testing (~> 2.0)+ actionpack (7.0.8.4)+ actionview (= 7.0.8.4)+ activesupport (= 7.0.8.4)+ rack (~> 2.0, >= 2.2.4)rack-test (>= 0.6.3)- rails-dom-testing (~> 2.2)- rails-html-sanitizer (~> 1.6)- actionview (7.1.3.4)- activesupport (= 7.1.3.4)+ rails-dom-testing (~> 2.0)+ rails-html-sanitizer (~> 1.0, >= 1.2.0)+ actionview (7.0.8.4)+ activesupport (= 7.0.8.4)builder (~> 3.1)- erubi (~> 1.11)- rails-dom-testing (~> 2.2)- rails-html-sanitizer (~> 1.6)+ erubi (~> 1.4)+ rails-dom-testing (~> 2.0)+ rails-html-sanitizer (~> 1.1, >= 1.2.0)actionview_precompiler (0.4.0)actionview (>= 6.0.a)active_model_serializers (0.8.4)activemodel (>= 3.0)- activejob (7.1.3.4)- activesupport (= 7.1.3.4)+ activejob (7.0.8.4)+ activesupport (= 7.0.8.4)globalid (>= 0.3.6)- activemodel (7.1.3.4)- activesupport (= 7.1.3.4)- activerecord (7.1.3.4)- activemodel (= 7.1.3.4)- activesupport (= 7.1.3.4)- timeout (>= 0.4.0)- activesupport (7.1.3.4)- base64- bigdecimal+ activemodel (7.0.8.4)+ activesupport (= 7.0.8.4)+ activerecord (7.0.8.4)+ activemodel (= 7.0.8.4)+ activesupport (= 7.0.8.4)+ activesupport (7.0.8.4)concurrent-ruby (~> 1.0, >= 1.0.2)- connection_pool (>= 2.2.5)- drbi18n (>= 1.6, < 2)minitest (>= 5.1)- mutex_mtzinfo (~> 2.0)addressable (2.8.6)public_suffix (>= 2.0.2, < 6.0)@@ -185,10 +176,6 @@ GEMprogress (~> 3.0, >= 3.0.1)image_size (3.4.0)in_threads (1.6.0)- io-console (0.7.2)- irb (1.13.1)- rdoc (>= 4.0.0)- reline (>= 0.4.2)iso8601 (0.13.0)jmespath (1.6.2)json (2.7.2)@@ -334,8 +321,6 @@ GEMpry-stack_explorer (0.6.1)binding_of_caller (~> 1.0)pry (~> 0.13)- psych (5.1.2)- stringiopublic_suffix (5.1.1)puma (6.4.2)nio4r (~> 2.0)@@ -346,13 +331,8 @@ GEMrack-protection (3.2.0)base64 (>= 0.1.0)rack (~> 2.2, >= 2.2.4)- rack-session (1.0.2)- rack (< 3)rack-test (2.1.0)rack (>= 1.3)- rackup (1.0.0)- rack (< 3)- webrickrails-dom-testing (2.2.0)activesupport (>= 5.0.0)minitest@@ -367,14 +347,13 @@ GEMrails_multisite (6.0.0)activerecord (>= 6.0)railties (>= 6.0)- railties (7.1.3.4)- actionpack (= 7.1.3.4)- activesupport (= 7.1.3.4)- irb- rackup (>= 1.0.0)+ railties (7.0.8.4)+ actionpack (= 7.0.8.4)+ activesupport (= 7.0.8.4)+ method_sourcerake (>= 12.2)- thor (~> 1.0, >= 1.2.2)- zeitwerk (~> 2.6)+ thor (~> 1.0)+ zeitwerk (~> 2.5)rainbow (3.1.1)raindrops (0.20.1)rake (13.2.1)@@ -386,15 +365,11 @@ GEMmsgpack (>= 0.4.3)optimist (>= 3.0.0)rchardet (1.8.0)- rdoc (6.7.0)- psych (>= 4.0.0)redcarpet (3.6.0)redis (4.8.1)redis-namespace (1.11.0)redis (>= 4)regexp_parser (2.9.2)- reline (0.5.8)- io-console (~> 0.5)request_store (1.7.0)rack (>= 1.4)rexml (3.3.0)@@ -533,7 +508,6 @@ GEMsqlite3 (1.7.3-x86_64-linux)sshkey (3.0.0)stackprof (0.2.26)- stringio (3.1.0)strscan (3.1.0)syntax_tree (6.2.0)prettier_print (>= 1.2.0)@@ -564,7 +538,6 @@ GEMaddressable (>= 2.8.0)crack (>= 0.3.2)hashdiff (>= 0.4.0, < 2.0.0)- webrick (1.8.1)websocket (1.2.10)xpath (3.2.0)nokogiri (~> 1.8)@@ -586,14 +559,14 @@ PLATFORMSx86_64-linuxDEPENDENCIES- actionmailer (~> 7.1.0)- actionpack (~> 7.1.0)- actionview (~> 7.1.0)+ actionmailer (< 7.1)+ actionpack (< 7.1)+ actionview (< 7.1)actionview_precompileractive_model_serializers (~> 0.8.3)- activemodel (~> 7.1.0)- activerecord (~> 7.1.0)- activesupport (~> 7.1.0)+ activemodel (< 7.1)+ activerecord (< 7.1)+ activesupport (< 7.1)addressableannotateaws-sdk-s3@@ -681,7 +654,7 @@ DEPENDENCIESrails-dom-testingrails_failoverrails_multisite- railties (~> 7.1.0)+ railties (< 7.1)rakerb-fseventrbtracediff --git a/app/models/post_revision.rb b/app/models/post_revision.rbindex 87f8c8d9145..7422726fec1 100644--- a/app/models/post_revision.rb+++ b/app/models/post_revision.rb@@ -4,7 +4,7 @@ class PostRevision < ActiveRecord::Basebelongs_to :postbelongs_to :user- serialize :modifications, type: Hash+ serialize :modifications, Hashafter_create :create_notificationdiff --git a/app/models/reviewable.rb b/app/models/reviewable.rbindex 3a0a228d265..3c03fae8a11 100644--- a/app/models/reviewable.rb+++ b/app/models/reviewable.rb@@ -33,12 +33,8 @@ class Reviewable < ActiveRecord::Basehas_many :reviewable_scores, -> { order(created_at: :desc) }, dependent: :destroyenum :status, { pending: 0, approved: 1, rejected: 2, ignored: 3, deleted: 4 }-- attribute :sensitivity, :integer- enum :sensitivity, { disabled: 0, low: 9, medium: 6, high: 3 }, scopes: false, suffix: true-- attribute :priority, :integerenum :priority, { low: 0, medium: 5, high: 10 }, scopes: false, suffix: true+ enum :sensitivity, { disabled: 0, low: 9, medium: 6, high: 3 }, scopes: false, suffix: truevalidates :reject_reason, length: { maximum: 2000 }diff --git a/app/models/translation_override.rb b/app/models/translation_override.rbindex d37e7301588..0e891f793ff 100644--- a/app/models/translation_override.rb+++ b/app/models/translation_override.rb@@ -45,7 +45,6 @@ class TranslationOverride < ActiveRecord::Basevalidate :check_interpolation_keys- attribute :status, :integerenum status: { up_to_date: 0, outdated: 1, invalid_interpolation_keys: 2, deprecated: 3 }def self.upsert!(locale, key, value)diff --git a/app/models/user.rb b/app/models/user.rbindex 47464ebc707..d3b2d8bd19e 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -158,9 +158,7 @@ class User < ActiveRecord::Baseunless: :should_skip_user_fields_validation?validates_associated :primary_email,- message: ->(_, user_email) do- user_email[:value]&.errors&.[](:email)&.first.to_s- end+ message: ->(_, user_email) { user_email[:value]&.errors&.[](:email)&.first }after_initialize :add_trust_leveldiff --git a/app/services/staff_action_logger.rb b/app/services/staff_action_logger.rbindex b52cc2602bc..7eb767919d8 100644--- a/app/services/staff_action_logger.rb+++ b/app/services/staff_action_logger.rb@@ -549,7 +549,7 @@ class StaffActionLoggerchanged_attributes = category.previous_changes.slice(*category_params.keys)- if !old_permissions.empty? && (old_permissions != category_params[:permissions].to_h)+ if !old_permissions.empty? && (old_permissions != category_params[:permissions])changed_attributes.merge!(permissions: [old_permissions.to_json, category_params[:permissions].to_json],)diff --git a/config/application.rb b/config/application.rbindex a5f5b728be0..2e214e1c5a9 100644--- a/config/application.rb+++ b/config/application.rb@@ -90,7 +90,7 @@ module Discourse# tiny file needed by site settingsrequire "highlight_js"- config.load_defaults 7.0+ config.load_defaults 6.1config.active_record.cache_versioning = false # our custom cache class doesn’t support thisconfig.action_controller.forgery_protection_origin_check = falseconfig.active_record.belongs_to_required_by_default = false@@ -100,9 +100,6 @@ module DiscourseTime,Symbol,]- config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA1- config.action_dispatch.cookies_serializer = :hybrid- config.action_controller.wrap_parameters_by_default = false# we skip it cause we configure it in the initializer# the railtie for message_bus would insert it in the@@ -115,9 +112,8 @@ module DiscourseENV["DISCOURSE_MULTISITE_CONFIG_PATH"] || GlobalSetting.multisite_config_pathconfig.multisite_config_path = File.absolute_path(multisite_config_path, Rails.root)- config.autoload_lib(ignore: %w[common_passwords emoji generators javascripts tasks])- Rails.autoloaders.main.do_not_eager_load(config.root.join("lib"))# Custom directories with classes and modules you want to be autoloadable.+ config.autoload_paths << "#{root}/lib"config.autoload_paths << "#{root}/lib/guardian"config.autoload_paths << "#{root}/lib/i18n"config.autoload_paths << "#{root}/lib/validators"@@ -244,17 +240,6 @@ module Discourse# we got to clear the pool in case plugins connectActiveRecord::Base.connection_handler.clear_active_connections!-- # Mailers and controllers may have been patched by plugins and when the- # application is eager loaded, the list of public methods is cached.- # We need to invalidate the existing caches, otherwise the new actions- # won’t be seen by Rails.- if Rails.configuration.eager_load- AbstractController::Base.descendants.each do |controller|- controller.clear_action_methods!- controller.action_methods- end- endendrequire "rbtrace" if ENV["RBTRACE"] == "1"diff --git a/config/environments/development.rb b/config/environments/development.rbindex 6609ecf373b..1ea67794833 100644--- a/config/environments/development.rb+++ b/config/environments/development.rb@@ -99,11 +99,4 @@ Discourse::Application.configure doendconfig.hosts << /\A(([a-z0-9-]+)\.)*localhost(\:\d+)?\Z/-- config.generators.after_generate do |files|- parsable_files = files.filter { |file| file.end_with?(".rb") }- unless parsable_files.empty?- system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)- end- endenddiff --git a/config/environments/test.rb b/config/environments/test.rbindex 66f7e3f32b8..7f6bd425fdf 100644--- a/config/environments/test.rb+++ b/config/environments/test.rb@@ -26,7 +26,7 @@ Discourse::Application.configure do# production has "show exceptions" on so we better have it# in test as well- config.action_dispatch.show_exceptions = :all+ config.action_dispatch.show_exceptions = true# Disable request forgery protection in test environmentconfig.action_controller.allow_forgery_protection = false@@ -65,7 +65,6 @@ Discourse::Application.configure do# Catch missing translations during test runs.config.i18n.raise_on_missing_translations = true- config.i18n.load_path += Dir[Rails.root.join("spec", "support", "locales", "**", "*.yml")]config.after_initialize doActiveRecord::LogSubscriber.backtrace_cleaner.add_silencer do |line|diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rbindex d43a24334ac..d5ee5c2da24 100644--- a/config/initializers/002-rails_failover.rb+++ b/config/initializers/002-rails_failover.rb@@ -19,7 +19,7 @@ if defined?(RailsFailover::Redis)SiteSetting.refresh!end- RailsFailover::Redis.logger = Rails.logger.broadcasts.first+ RailsFailover::Redis.logger = Rails.logger.chained.first if Rails.logger.respond_to? :chainedendif defined?(RailsFailover::ActiveRecord)diff --git a/config/initializers/100-logster.rb b/config/initializers/100-logster.rbindex 9248e35e326..0a33877d3d5 100644--- a/config/initializers/100-logster.rb+++ b/config/initializers/100-logster.rb@@ -2,7 +2,7 @@if GlobalSetting.skip_redis?Rails.application.reloader.to_prepare do- Rails.logger.stop_broadcasting_to(Logster.logger) if defined?(Logster::Logger) && Logster.logger+ Rails.logger = Rails.logger.chained.first if Rails.logger.respond_to? :chainedendreturnend@@ -10,12 +10,12 @@ endif Rails.env.development? && !Sidekiq.server? && ENV["RAILS_LOGS_STDOUT"] == "1"Rails.application.config.after_initialize doconsole = ActiveSupport::Logger.new(STDOUT)- original_logger = Rails.logger.broadcasts.first+ original_logger = Rails.logger.chained.firstconsole.formatter = original_logger.formatterconsole.level = original_logger.levelunless ActiveSupport::Logger.logger_outputs_to?(original_logger, STDOUT)- Rails.logger.broadcast_to(console)+ original_logger.extend(ActiveSupport::Logger.broadcast(console))endendend@@ -118,7 +118,10 @@ RailsMultisite::ConnectionManagement.each_connection doendif Rails.configuration.multisite- Rails.logger.broadcasts.first.formatter = RailsMultisite::Formatter.new+ if Rails.logger.respond_to? :chained+ chained = Rails.logger.chained+ chained && chained.first.formatter = RailsMultisite::Formatter.new+ endendLogster.config.project_directories = [diff --git a/config/initializers/100-quiet_logger.rb b/config/initializers/100-quiet_logger.rbindex d72387be9e2..ef156499861 100644--- a/config/initializers/100-quiet_logger.rb+++ b/config/initializers/100-quiet_logger.rb@@ -11,13 +11,13 @@ module DiscourseRackQuietAssetsLogger(env["PATH_INFO"].index("/service-worker") == 0) ||(env["PATH_INFO"].index("mini-profiler-resources") == 0) ||(env["PATH_INFO"].index("/srv/status") == 0)- if defined?(::Logster::Logger) && Logster.logger+ if ::Logster::Logger === Rails.loggeroverride = true- Logster.logger.override_level = Logger::ERROR+ Rails.logger.override_level = Logger::ERRORendend- super(env).tap { Logster.logger.override_level = nil if override }+ super(env).tap { Rails.logger.override_level = nil if override }endenddiff --git a/config/initializers/100-silence_logger.rb b/config/initializers/100-silence_logger.rbindex 4dcf4a784db..e01b29816f7 100644--- a/config/initializers/100-silence_logger.rb+++ b/config/initializers/100-silence_logger.rb@@ -20,16 +20,16 @@ class SilenceLogger < Rails::Rack::Loggerif env[HTTP_X_SILENCE_LOGGER] || @opts[:silenced].include?(path_info) ||path_info.start_with?("/logs") || path_info.start_with?("/user_avatar") ||path_info.start_with?("/letter_avatar")- if defined?(::Logster::Logger) && Logster.logger+ if ::Logster::Logger === Rails.loggeroverride = true- Logster.logger.override_level = Logger::WARN+ Rails.logger.override_level = Logger::WARNend@app.call(env)elsesuper(env)endensure- Logster.logger.override_level = nil if override+ Rails.logger.override_level = nil if overrideendenddiff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rbindex b17cb7f3c77..3baac8b4b46 100644--- a/config/initializers/101-lograge.rb+++ b/config/initializers/101-lograge.rb@@ -111,8 +111,8 @@ Rails.application.config.to_prepare do# Remove ActiveSupport::Logger from the chain and replace with Lograge's# logger- Rails.logger.stop_broadcasting_to(Rails.logger.broadcasts.last)- Rails.logger.broadcast_to(config.lograge.logger)+ Rails.logger.chained.pop+ Rails.logger.chain(config.lograge.logger)endendenddiff --git a/config/initializers/102-truncate-logs.rb b/config/initializers/102-truncate-logs.rbindex 29601aa1f4b..b1276f3d967 100644--- a/config/initializers/102-truncate-logs.rb+++ b/config/initializers/102-truncate-logs.rb@@ -22,6 +22,10 @@ if Rails.env.production? || ENV["ENABLE_LOGS_TRUNCATION"] == "1"endRails.application.config.to_prepare do- Rails.logger.broadcasts.each { |logger| set_or_extend_truncate_logs_formatter(logger) }+ set_or_extend_truncate_logs_formatter(Rails.logger)++ if Rails.logger.respond_to? :chained+ Rails.logger.chained.each { |logger| set_or_extend_truncate_logs_formatter(logger) }+ endendenddiff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rbnew file mode 100644index 00000000000..fdbf91e62fc--- /dev/null+++ b/config/initializers/new_framework_defaults_7_0.rb@@ -0,0 +1,106 @@+# frozen_string_literal: true++# Be sure to restart your server when you modify this file.+#+# This file eases your Rails 7.0 framework defaults upgrade.+#+# Uncomment each configuration one by one to switch to the new default.+# Once your application is ready to run with all new defaults, you can remove+# this file and set the `config.load_defaults` to `7.0`.+#+# Read the Guide for Upgrading Ruby on Rails for more info on each option.+# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html++# `button_to` view helper will render `<button>` element, regardless of whether+# or not the content is passed as the first argument or as a block.+Rails.application.config.action_view.button_to_generates_button_tag = true++# `stylesheet_link_tag` view helper will not render the media attribute by default.+Rails.application.config.action_view.apply_stylesheet_media_default = false++# Change the digest class for the key generators to `OpenSSL::Digest::SHA256`.+# Changing this default means invalidate all encrypted messages generated by+# your application and, all the encrypted cookies. Only change this after you+# rotated all the messages using the key rotator.+#+# See upgrading guide for more information on how to build a rotator.+# https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html+# Rails.application.config.active_support.key_generator_hash_digest_class = OpenSSL::Digest::SHA256++# Change the digest class for ActiveSupport::Digest.+# Changing this default means that for example Etags change and+# various cache keys leading to cache invalidation.+Rails.application.config.active_support.hash_digest_class = OpenSSL::Digest::SHA256++# Don't override ActiveSupport::TimeWithZone.name and use the default Ruby+# implementation.+Rails.application.config.active_support.remove_deprecated_time_with_zone_name = true++# Change the format of the cache entry.+# Changing this default means that all new cache entries added to the cache+# will have a different format that is not supported by Rails 6.1 applications.+# Only change this value after your application is fully deployed to Rails 7.0+# and you have no plans to rollback.+Rails.application.config.active_support.cache_format_version = 7.0++# Calls `Rails.application.executor.wrap` around test cases.+# This makes test cases behave closer to an actual request or job.+# Several features that are normally disabled in test, such as Active Record query cache+# and asynchronous queries will then be enabled.+Rails.application.config.active_support.executor_around_test_case = true++# Define the isolation level of most of Rails internal state.+# If you use a fiber based server or job processor, you should set it to `:fiber`.+# Otherwise the default of `:thread` if preferable.+Rails.application.config.active_support.isolation_level = :thread++# Set both the `:open_timeout` and `:read_timeout` values for `:smtp` delivery method.+Rails.application.config.action_mailer.smtp_timeout = 5++# Automatically infer `inverse_of` for associations with a scope.+Rails.application.config.active_record.automatic_scope_inversing = true++# Raise when running tests if fixtures contained foreign key violations+Rails.application.config.active_record.verify_foreign_keys_for_fixtures = true++# Disable partial inserts.+# This default means that all columns will be referenced in INSERT queries+# regardless of whether they have a default or not.+Rails.application.config.active_record.partial_inserts = false+#+# Protect from open redirect attacks in `redirect_back_or_to` and `redirect_to`.+Rails.application.config.action_controller.raise_on_open_redirects = true++# If you're upgrading and haven't set `cookies_serializer` previously, your cookie serializer+# was `:marshal`. Convert all cookies to JSON, using the `:hybrid` formatter.+#+# If you're confident all your cookies are JSON formatted, you can switch to the `:json` formatter.+#+# Continue to use `:marshal` for backward-compatibility with old cookies.+#+# If you have configured the serializer elsewhere, you can remove this.+#+# See https://guides.rubyonrails.org/action_controller_overview.html#cookies for more information.+Rails.application.config.action_dispatch.cookies_serializer = :hybrid++# Enable parameter wrapping for JSON.+# Previously this was set in an initializer. It's fine to keep using that initializer if you've customized it.+# To disable parameter wrapping entirely, set this config to `false`.+# Rails.application.config.action_controller.wrap_parameters_by_default = true++# Specifies whether generated namespaced UUIDs follow the RFC 4122 standard for namespace IDs provided as a+# `String` to `Digest::UUID.uuid_v3` or `Digest::UUID.uuid_v5` method calls.+#+# See https://guides.rubyonrails.org/configuring.html#config-active-support-use-rfc4122-namespaced-uuids for+# more information.+Rails.application.config.active_support.use_rfc4122_namespaced_uuids = true++# Change the default headers to disable browsers' flawed legacy XSS protection.+Rails.application.config.action_dispatch.default_headers = {+ "X-Frame-Options" => "SAMEORIGIN",+ "X-XSS-Protection" => "0",+ "X-Content-Type-Options" => "nosniff",+ "X-Download-Options" => "noopen",+ "X-Permitted-Cross-Domain-Policies" => "none",+ "Referrer-Policy" => "strict-origin-when-cross-origin",+}diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rbdeleted file mode 100644index 974cc2aa3a7..00000000000--- a/config/initializers/new_framework_defaults_7_1.rb+++ /dev/null@@ -1,224 +0,0 @@-# frozen_string_literal: true-# Be sure to restart your server when you modify this file.-#-# This file eases your Rails 7.1 framework defaults upgrade.-#-# Uncomment each configuration one by one to switch to the new default.-# Once your application is ready to run with all new defaults, you can remove-# this file and set the `config.load_defaults` to `7.1`.-#-# Read the Guide for Upgrading Ruby on Rails for more info on each option.-# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html--# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able-# to manually require files that are managed by the autoloader, which you shouldn't do anyway.-# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size-# of the bootsnap cache if you use it.-# Rails.application.config.add_autoload_paths_to_load_path = false--# Remove the default X-Download-Options headers since it is used only by Internet Explorer.-# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`.-# Rails.application.config.action_dispatch.default_headers = {-# "X-Frame-Options" => "SAMEORIGIN",-# "X-XSS-Protection" => "0",-# "X-Content-Type-Options" => "nosniff",-# "X-Permitted-Cross-Domain-Policies" => "none",-# "Referrer-Policy" => "strict-origin-when-cross-origin"-# }--# Do not treat an `ActionController::Parameters` instance-# as equal to an equivalent `Hash` by default.-# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false--# Active Record Encryption now uses SHA-256 as its hash digest algorithm. Important: If you have-# data encrypted with previous Rails versions, there are two scenarios to consider:-#-# 1. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default-# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too:-# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1-# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default-# in 7.0), then you need to configure SHA-256 for Active Record Encryption:-# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256-#-# If you don't currently have data encrypted with Active Record encryption, you can disable this setting to-# configure the default behavior starting 7.1+:-# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false--# No longer run after_commit callbacks on the first of multiple Active Record-# instances to save changes to the same database row within a transaction.-# Instead, run these callbacks on the instance most likely to have internal-# state which matches what was committed to the database, typically the last-# instance to save.-# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false--# Configures SQLite with a strict strings mode, which disables double-quoted string literals.-#-# SQLite has some quirks around double-quoted string literals.-# It first tries to consider double-quoted strings as identifier names, but if they don't exist-# it then considers them as string literals. Because of this, typos can silently go unnoticed.-# For example, it is possible to create an index for a non existing column.-# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details.-# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true--# Disable deprecated singular associations names-# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false--# Enable the Active Job `BigDecimal` argument serializer, which guarantees-# roundtripping. Without this serializer, some queue adapters may serialize-# `BigDecimal` arguments as simple (non-roundtrippable) strings.-#-# When deploying an application with multiple replicas, old (pre-Rails 7.1)-# replicas will not be able to deserialize `BigDecimal` arguments from this-# serializer. Therefore, this setting should only be enabled after all replicas-# have been successfully upgraded to Rails 7.1.-# Rails.application.config.active_job.use_big_decimal_serializer = true--# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or-# `write` are given an invalid `expires_at` or `expires_in` time.-# Options are `true`, and `false`. If `false`, the exception will be reported-# as `handled` and logged instead.-# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true--# Specify whether Query Logs will format tags using the SQLCommenter format-# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format.-# Options are `:legacy` and `:sqlcommenter`.-# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter--# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier`-# instances.-#-# The legacy default is `:marshal`, which is a potential vector for-# deserialization attacks in cases where a message signing secret has been-# leaked.-#-# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and-# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing-# with `Marshal` so that legacy messages can still be read.-#-# In Rails 7.2, the default will become `:json` which serializes and-# deserializes with `ActiveSupport::JSON` only.-#-# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`,-# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack`-# can roundtrip some Ruby types that are not supported by JSON, and may provide-# improved performance, but it requires the `msgpack` gem.-#-# For more information, see-# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer-#-# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers-# that have not yet been upgraded must be able to read messages from upgraded-# servers, first deploy without changing the serializer, then set the serializer-# in a subsequent deploy.-# Rails.application.config.active_support.message_serializer = :json_allow_marshal--# Enable a performance optimization that serializes message data and metadata-# together. This changes the message format, so messages serialized this way-# cannot be read by older versions of Rails. However, messages that use the old-# format can still be read, regardless of whether this optimization is enabled.-#-# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have-# not yet been upgraded must be able to read messages from upgraded servers,-# leave this optimization off on the first deploy, then enable it on a-# subsequent deploy.-# Rails.application.config.active_support.use_message_serializer_for_metadata = true--# Set the maximum size for Rails log files.-#-# `config.load_defaults 7.1` does not set this value for environments other than-# development and test.-#-# if Rails.env.local?-# Rails.application.config.log_file_size = 100 * 1024 * 1024-# end--# Enable raising on assignment to attr_readonly attributes. The previous-# behavior would allow assignment but silently not persist changes to the-# database.-# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true--# Enable validating only parent-related columns for presence when the parent is mandatory.-# The previous behavior was to validate the presence of the parent record, which performed an extra query-# to get the parent every time the child record was updated, even when parent has not changed.-# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false--# Enable precompilation of `config.filter_parameters`. Precompilation can-# improve filtering performance, depending on the quantity and types of filters.-# Rails.application.config.precompile_filter_parameters = true--# Enable before_committed! callbacks on all enrolled records in a transaction.-# The previous behavior was to only run the callbacks on the first copy of a record-# if there were multiple copies of the same record enrolled in the transaction.-# Rails.application.config.active_record.before_committed_on_all_records = true--# Disable automatic column serialization into YAML.-# To keep the historic behavior, you can set it to `YAML`, however it is-# recommended to explicitly define the serialization method for each column-# rather than to rely on a global default.-# Rails.application.config.active_record.default_column_serializer = nil--# Enable a performance optimization that serializes Active Record models-# in a faster and more compact way.-#-# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have-# not yet been upgraded must be able to read caches from upgraded servers,-# leave this optimization off on the first deploy, then enable it on a-# subsequent deploy.-# Rails.application.config.active_record.marshalling_format_version = 7.1--# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model.-# This matches the behaviour of all other callbacks.-# In previous versions of Rails, they ran in the inverse order.-# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true--# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`.-#-# Rails.application.config.active_record.commit_transaction_on_non_local_return = true--# Controls when to generate a value for <tt>has_secure_token</tt> declarations.-#-# Rails.application.config.active_record.generate_secure_token_on = :initialize--# ** Please read carefully, this must be configured in config/application.rb **-# Change the format of the cache entry.-# Changing this default means that all new cache entries added to the cache-# will have a different format that is not supported by Rails 7.0-# applications.-# Only change this value after your application is fully deployed to Rails 7.1-# and you have no plans to rollback.-# When you're ready to change format, add this to `config/application.rb` (NOT-# this file):-# config.active_support.cache_format_version = 7.1--# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your-# platform.-#-# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant-# sanitizers if they are supported, else fall back to HTML4 sanitizers.-#-# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor.-#-# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor--# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your-# platform.-#-# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant-# sanitizers if they are supported, else fall back to HTML4 sanitizers.-#-# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor.-#-# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor--# Configure the log level used by the DebugExceptions middleware when logging-# uncaught exceptions during requests-# Rails.application.config.action_dispatch.debug_exception_log_level = :error--# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5-# parsers.-#-# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4.-#-# In previous versions of Rails, these test helpers always used an HTML4 parser.-#-# Rails.application.config.dom_testing_default_html_version = :html5diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 49a3b4052fc..fe9dbcd334a 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -323,7 +323,6 @@ en:other: is the wrong length (should be %{count} characters)other_than: "must be other than %{count}"auth_overrides_username: "Username needs to be updated on authentication provider side, since `auth_overrides_username` setting is enabled."- required: "must exist"template:body: ! "There were problems with the following fields:"header:diff --git a/lib/discourse.rb b/lib/discourse.rbindex 4957b4c174c..2f910cf081a 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -954,7 +954,14 @@ module Discoursedef self.warn(message, env = nil)append = env ? (+" ") << env.map { |k, v| "#{k}: #{v}" }.join(" ") : ""- loggers = Rails.logger.broadcasts+ if !(Logster::Logger === Rails.logger)+ Rails.logger.warn("#{message}#{append}")+ return+ end++ loggers = [Rails.logger]+ loggers.concat(Rails.logger.chained) if Rails.logger.chained+logster_env = envif old_env = Thread.current[Logster::Logger::LOGSTER_ENV]@@ -1109,7 +1116,16 @@ module Discourseendend+ schema_cache = ActiveRecord::Base.connection.schema_cache+RailsMultisite::ConnectionManagement.safe_each_connection do+ # load up schema cache for all multisite assuming all dbs have+ # an identical schema+ dup_cache = schema_cache.dup+ # this line is not really needed, but just in case the+ # underlying implementation changes lets give it a shot+ dup_cache.connection = nil+ ActiveRecord::Base.connection.schema_cache = dup_cacheI18n.t(:posts)# this will force Cppjieba to preload if any site has itdiff --git a/lib/hijack.rb b/lib/hijack.rbindex 1e123fd6fc3..b7a76808440 100644--- a/lib/hijack.rb+++ b/lib/hijack.rb@@ -53,10 +53,10 @@ module Hijack# this trick avoids double render, also avoids any litter that the controller hooks# place on the responseinstance = controller_class.new- response = ActionDispatch::Response.new.tap { _1.request = request_copy }- instance.set_response!(response)- instance.set_request!(request_copy)+ response = ActionDispatch::Response.new+ instance.response = response+ instance.request = request_copyoriginal_headers&.each { |k, v| instance.response.headers[k] = v }view_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)diff --git a/lib/middleware/discourse_public_exceptions.rb b/lib/middleware/discourse_public_exceptions.rbindex c4ae0d673fb..d3666201608 100644--- a/lib/middleware/discourse_public_exceptions.rb+++ b/lib/middleware/discourse_public_exceptions.rb@@ -34,7 +34,7 @@ module Middlewareif exceptionbeginfake_controller = ApplicationController.new- fake_controller.set_response!(response)+ fake_controller.response = responsefake_controller.request = request = ActionDispatch::Request.new(env)# We can not re-dispatch bad mime typesdiff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rbindex e07adc8404b..3f890a61d40 100644--- a/lib/site_setting_extension.rb+++ b/lib/site_setting_extension.rb@@ -269,7 +269,7 @@ module SiteSettingExtensionenddef description(setting)- I18n.t("site_settings.#{setting}", base_path: Discourse.base_path, default: "")+ I18n.t("site_settings.#{setting}", base_path: Discourse.base_path)enddef keywords(setting)diff --git a/plugins/chat/app/models/chat/category_channel.rb b/plugins/chat/app/models/chat/category_channel.rbindex c303c191a3c..e23a37f1a7c 100644--- a/plugins/chat/app/models/chat/category_channel.rb+++ b/plugins/chat/app/models/chat/category_channel.rb@@ -2,7 +2,7 @@module Chatclass CategoryChannel < Channel- alias_method :category, :chatable+ alias_attribute :category, :chatabledelegate :read_restricted?, to: :categorydelegate :url, to: :chatable, prefix: truediff --git a/plugins/chat/app/models/chat/direct_message_channel.rb b/plugins/chat/app/models/chat/direct_message_channel.rbindex 2e5a1b8e2a9..ede478a9713 100644--- a/plugins/chat/app/models/chat/direct_message_channel.rb+++ b/plugins/chat/app/models/chat/direct_message_channel.rb@@ -2,7 +2,7 @@module Chatclass DirectMessageChannel < Channel- alias_method :direct_message, :chatable+ alias_attribute :direct_message, :chatabledef direct_message_channel?truediff --git a/plugins/chat/spec/system/visit_channel_spec.rb b/plugins/chat/spec/system/visit_channel_spec.rbindex c268b41640d..506333ebd7e 100644--- a/plugins/chat/spec/system/visit_channel_spec.rb+++ b/plugins/chat/spec/system/visit_channel_spec.rb@@ -183,7 +183,7 @@ RSpec.describe "Visit channel", type: :system docontext "when visiting a specific channel message ID then navigating to another channel" dofab!(:early_message) { Fabricate(:chat_message, chat_channel: category_channel_1) }fab!(:other_channel) do- Fabricate(:category_channel, chatable: category_channel_1.chatable)+ Fabricate(:category_channel, category: category_channel_1.chatable)endfab!(:other_channel_message) { Fabricate(:chat_message, chat_channel: other_channel) }diff --git a/spec/fixtures/mmdb/mmdb.tar.gz b/spec/fixtures/mmdb/mmdb.tar.gzdeleted file mode 100644index 7c43a25327a..00000000000Binary files a/spec/fixtures/mmdb/mmdb.tar.gz and /dev/null differdiff --git a/spec/integration/invalid_request_spec.rb b/spec/integration/invalid_request_spec.rbindex b845c3ef0e6..6d19bcb9c68 100644--- a/spec/integration/invalid_request_spec.rb+++ b/spec/integration/invalid_request_spec.rb@@ -1,11 +1,12 @@# frozen_string_literal: trueRSpec.describe "invalid requests", type: :request do- let(:fake_logger) { FakeLogger.new }-- before { Rails.logger.broadcast_to(fake_logger) }+ before do+ @orig_logger = Rails.logger+ Rails.logger = @fake_logger = FakeLogger.new+ end- after { Rails.logger.stop_broadcasting_to(fake_logger) }+ after { Rails.logger = @orig_logger }it "handles NotFound with invalid json body" dopost "/latest.json",@@ -14,8 +15,8 @@ RSpec.describe "invalid requests", type: :request do"content-type" => "application/json",}expect(response.status).to eq(404)- expect(fake_logger.warnings.length).to eq(0)- expect(fake_logger.errors.length).to eq(0)+ expect(@fake_logger.warnings.length).to eq(0)+ expect(@fake_logger.errors.length).to eq(0)endit "handles EOFError when multipart request is malformed" do@@ -26,14 +27,14 @@ RSpec.describe "invalid requests", type: :request do"content-length" => "1",}expect(response.status).to eq(400)- expect(fake_logger.warnings.length).to eq(0)- expect(fake_logger.errors.length).to eq(0)+ expect(@fake_logger.warnings.length).to eq(0)+ expect(@fake_logger.errors.length).to eq(0)endit "handles invalid parameters" dopost "/latest.json", params: { "foo" => "\255bar" }expect(response.status).to eq(404)- expect(fake_logger.warnings.length).to eq(0)- expect(fake_logger.errors.length).to eq(0)+ expect(@fake_logger.warnings.length).to eq(0)+ expect(@fake_logger.errors.length).to eq(0)endenddiff --git a/spec/lib/auth/default_current_user_provider_spec.rb b/spec/lib/auth/default_current_user_provider_spec.rbindex e06a711814e..cc0f1983829 100644--- a/spec/lib/auth/default_current_user_provider_spec.rb+++ b/spec/lib/auth/default_current_user_provider_spec.rb@@ -21,11 +21,11 @@ RSpec.describe Auth::DefaultCurrentUserProvider doenddef get_cookie_info(cookie_jar, name)- response = ActionDispatch::Response.new+ headers = {}cookie_jar.always_write_cookie = true- cookie_jar.write(response)+ cookie_jar.write(headers)- header = response.headers["Set-Cookie"]+ header = headers["Set-Cookie"]return if header.nil?info = {}diff --git a/spec/lib/email/message_builder_spec.rb b/spec/lib/email/message_builder_spec.rbindex 9b27835a2b9..3ad1fbd5300 100644--- a/spec/lib/email/message_builder_spec.rb+++ b/spec/lib/email/message_builder_spec.rb@@ -14,9 +14,9 @@ RSpec.describe Email::MessageBuilder dolet(:body_modifier_block) { Proc.new { |subject, opts| "modified body" } }let(:visit_link_to_respond_modifier_block) do- Proc.new { |subject, opts| "modified_visit_link_to_respond" }+ Proc.new { |subject, opts| "modified visit_link_to_respond" }end- let(:reply_by_email_modifier_block) { Proc.new { |subject, opts| "modified_reply_by_email" } }+ let(:reply_by_email_modifier_block) { Proc.new { |subject, opts| "modified reply_by_email" } }it "has the correct to address" doexpect(build_args[:to]).to eq(to_address)@@ -69,7 +69,7 @@ RSpec.describe Email::MessageBuilder doinclude_respond_instructions: true,url: "http://localhost",)- expect(builder2.reply_by_email_key).to equal("modified_reply_by_email")+ expect(builder2.reply_by_email_key).to equal("modified reply_by_email")ensureDiscoursePluginRegistry.unregister_modifier(plugin_instance,@@ -93,7 +93,7 @@ RSpec.describe Email::MessageBuilder dourl: "http://localhost",)expect(builder2.template_args[:respond_instructions]).to include(- "modified_visit_link_to_respond",+ "modified visit_link_to_respond",)ensureDiscoursePluginRegistry.unregister_modifier(diff --git a/spec/lib/hijack_spec.rb b/spec/lib/hijack_spec.rbindex 041cdfd1de6..1c30928872a 100644--- a/spec/lib/hijack_spec.rb+++ b/spec/lib/hijack_spec.rb@@ -14,7 +14,7 @@ RSpec.describe Hijack doself.request = ActionController::TestRequest.new(env, nil, nil)# we need this for the 418- set_response!(ActionDispatch::Response.new)+ self.response = ActionDispatch::Response.newenddef hijack_test(&blk)@@ -22,10 +22,12 @@ RSpec.describe Hijack doendend- let(:tester) { Hijack::Tester.new }+ let :tester do+ Hijack::Tester.new+ enddescribe "Request Tracker integration" do- let(:logger) do+ let :logger dolambda do |env, data|@calls += 1@status = data[:status]@@ -179,7 +181,7 @@ RSpec.describe Hijack doendresult =- "HTTP/1.1 302 Found\r\nLocation: http://awesome.com\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 0\r\nConnection: close\r\nX-Runtime: 1.000000\r\n\r\n"+ "HTTP/1.1 302 Found\r\nLocation: http://awesome.com\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 84\r\nConnection: close\r\nX-Runtime: 1.000000\r\n\r\n<html><body>You are being <a href=\"http://awesome.com\">redirected</a>.</body></html>"expect(tester.io.string).to eq(result)enddiff --git a/spec/lib/migration/safe_migrate_spec.rb b/spec/lib/migration/safe_migrate_spec.rbindex 9fe91b84e9f..3ed5413330a 100644--- a/spec/lib/migration/safe_migrate_spec.rb+++ b/spec/lib/migration/safe_migrate_spec.rb@@ -9,12 +9,11 @@ RSpec.describe Migration::SafeMigrate doenddef migrate_up(path)- migrations = ActiveRecord::MigrationContext.new(path).migrations+ migrations = ActiveRecord::MigrationContext.new(path, ActiveRecord::SchemaMigration).migrationsActiveRecord::Migrator.new(:up,migrations,- ActiveRecord::Base.connection.schema_migration,- ActiveRecord::Base.connection.internal_metadata,+ ActiveRecord::SchemaMigration,migrations.first.version,).runend@@ -78,7 +77,7 @@ RSpec.describe Migration::SafeMigrate dooutput = capture_stdout { migrate_up(path) }- expect(output).to include("change_column_null(:users, :username, true, nil)")+ expect(output).to include("change_column_null(:users, :username, true)")endit "supports being disabled" dodiff --git a/spec/lib/site_setting_extension_spec.rb b/spec/lib/site_setting_extension_spec.rbindex b717b418773..44ac6fb7af6 100644--- a/spec/lib/site_setting_extension_spec.rb+++ b/spec/lib/site_setting_extension_spec.rb@@ -422,7 +422,9 @@ RSpec.describe SiteSettingExtension doendend- let(:test_enum_class) { TestEnumClass }+ let :test_enum_class do+ TestEnumClass+ endbefore dosettings.setting(:test_enum, "en", enum: test_enum_class)diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rbindex e3e1a13607d..dc660c5b166 100644--- a/spec/models/admin_dashboard_data_spec.rb+++ b/spec/models/admin_dashboard_data_spec.rb@@ -42,7 +42,7 @@ RSpec.describe AdminDashboardData doenddescribe "#problem_message_check" do- let(:key) { "new_key" }+ let(:key) { AdminDashboardData.problem_messages.first }after { described_class.clear_problem_message(key) }diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 4b06b324de6..7a26329e532 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -678,7 +678,7 @@ RSpec.describe User doquoted_post = create_post(user: user, topic: topic, post_number: 1, raw: "quoted post")post = create_post(raw: <<~RAW)Lorem ipsum-+[quote="#{user.username}, post:1, topic:#{quoted_post.topic.id}"]quoted post[/quote]diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 943732be66e..c127fa662dc 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -245,7 +245,7 @@ RSpec.configure do |config|CachedCounting.disablebegin- ActiveRecord::Migration.check_all_pending!+ ActiveRecord::Migration.check_pending!rescue ActiveRecord::PendingMigrationErrorraise "There are pending migrations, run RAILS_ENV=test bin/rake db:migrate"end@@ -718,7 +718,7 @@ RSpec.configure do |config|endconfig.after(:each, type: :multisite) do- ActiveRecord::Base.connection_handler.clear_all_connections!+ ActiveRecord::Base.clear_all_connections!Rails.configuration.multisite = false # rubocop:disable Discourse/NoDirectMultisiteManipulationRailsMultisite::ConnectionManagement.clear_settings!ActiveRecord::Base.establish_connectiondiff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rbindex 62ecca5ff5d..621db5936df 100644--- a/spec/requests/application_controller_spec.rb+++ b/spec/requests/application_controller_spec.rb@@ -268,7 +268,7 @@ RSpec.describe ApplicationController doexpect(log).not_to include("exception app middleware")- expect(response.status).to eq(400)+ expect(response.parsed_body).to eq("status" => 400, "error" => "Bad Request")endenddiff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rbindex 5d0a23bbf8d..1aecd088b26 100644--- a/spec/requests/categories_controller_spec.rb+++ b/spec/requests/categories_controller_spec.rb@@ -39,16 +39,16 @@ RSpec.describe CategoriesController doit "redirects /category paths to /c paths" doget "/category/uncategorized"- expect(response).to have_http_status(:found)- expect(response).to redirect_to("/c/uncategorized")+ expect(response.status).to eq(302)+ expect(response.body).to include("c/uncategorized")endit "respects permalinks before redirecting /category paths to /c paths" do_perm = Permalink.create!(url: "category/something", category_id: category.id)get "/category/something"- expect(response).to have_http_status(:moved_permanently)- expect(response).to redirect_to(%r{/c/#{category.slug}})+ expect(response.status).to eq(301)+ expect(response.body).to include(category.slug)endit "returns the right response for a normal user" dodiff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rbindex f21a5c92ddb..53284cc46f0 100644--- a/spec/requests/embed_controller_spec.rb+++ b/spec/requests/embed_controller_spec.rb@@ -190,6 +190,8 @@ RSpec.describe EmbedController docontext "with a host" dofab!(:embeddable_host)+ before { Jobs.run_immediately! }+it "doesn't raise an error with no referer" doget "/embed/comments", params: { embed_url: embed_url }@@ -244,8 +246,6 @@ RSpec.describe EmbedController doendcontext "with success" do- before { Jobs.run_immediately! }-it "tells the topic retriever to work when no previous embed is found" doTopicRetriever.any_instance.expects(:retrieve)diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rbindex 25ad4e17853..df8867b276f 100644--- a/spec/requests/session_controller_spec.rb+++ b/spec/requests/session_controller_spec.rb@@ -946,7 +946,7 @@ RSpec.describe SessionController doget "/session/sso_login", params: Rack::Utils.parse_query(sso.payload), headers: headersexpect(response.status).to eq(403)- expect(response.body).to include(I18n.t("discourse_connect.account_not_approved"))+ expect(response.parsed_body).to include(I18n.t("discourse_connect.account_not_approved"))end.to change { User.count }.by(1)logged_on_user = Discourse.current_user_provider.new(request.env).current_user@@ -1124,7 +1124,7 @@ RSpec.describe SessionController dologin_with_sso_and_inviteexpect(response.status).to eq(403)- expect(response.body).to include(I18n.t("discourse_connect.account_not_approved"))+ expect(response.parsed_body).to include(I18n.t("discourse_connect.account_not_approved"))expect(invite.reload.redeemed?).to eq(true)user = User.find_by_email("[email protected]")diff --git a/spec/requests/uploads_controller_multisite_spec.rb b/spec/requests/uploads_controller_multisite_spec.rbindex 5da91841111..badb310ef9d 100644--- a/spec/requests/uploads_controller_multisite_spec.rb+++ b/spec/requests/uploads_controller_multisite_spec.rb@@ -8,13 +8,13 @@ RSpec.describe UploadsController, type: %i[multisite request] dosetup_s3SiteSetting.secure_uploads = trueupload.update(secure: true)- sign_in(user)- freeze_timeendit "redirects to the signed_url_for_path with the multisite DB name in the url" do+ sign_in(user)+ freeze_timeget upload.short_path- expect(response).to redirect_to(/#{RailsMultisite::ConnectionManagement.current_db}/)+ expect(response.body).to include(RailsMultisite::ConnectionManagement.current_db)endenddiff --git a/spec/support/fake_logger.rb b/spec/support/fake_logger.rbindex d7c291d9cef..15c1a9e5f32 100644--- a/spec/support/fake_logger.rb+++ b/spec/support/fake_logger.rb@@ -1,7 +1,7 @@# frozen_string_literal: trueclass FakeLogger- attr_reader :debugs, :infos, :warnings, :errors, :fatals, :severities+ attr_reader :debugs, :infos, :warnings, :errors, :fatalsattr_accessor :leveldef initialize@@ -11,10 +11,9 @@ class FakeLogger@errors = []@fatals = []@level = Logger::DEBUG- @severities = { 0 => :debugs, 1 => :infos, 2 => :warnings, 3 => :errors, 4 => :fatals }end- def debug(message = nil)+ def debug(message)@debugs << messageend@@ -30,7 +29,7 @@ class FakeLogger@level <= Logger::INFOend- def warn(message = nil)+ def warn(message)@warnings << messageend@@ -38,7 +37,7 @@ class FakeLogger@level <= Logger::WARNend- def error(message = nil)+ def error(message)@errors << messageend@@ -46,7 +45,7 @@ class FakeLogger@level <= Logger::ERRORend- def fatal(message = nil)+ def fatal(message)@fatals << messageend@@ -56,12 +55,4 @@ class FakeLoggerdef formatterend-- def add(severity, message = nil, progname = nil)- public_send(severities[severity]) << message- end-- def broadcasts- [self]- endenddiff --git a/spec/support/i18n_helpers.rb b/spec/support/i18n_helpers.rbindex 99f2713a947..4e178d59042 100644--- a/spec/support/i18n_helpers.rb+++ b/spec/support/i18n_helpers.rb@@ -2,12 +2,9 @@module I18nHelpersdef allow_missing_translations- original_handler = I18n.exception_handler- I18n.exception_handler = nilRails.application.config.i18n.raise_on_missing_translations = falseyieldensure- I18n.exception_handler = original_handlerRails.application.config.i18n.raise_on_missing_translations = trueendenddiff --git a/spec/support/locales/dashboard.en.yml b/spec/support/locales/dashboard.en.ymldeleted file mode 100644index 9b0bfc1fe5c..00000000000--- a/spec/support/locales/dashboard.en.yml+++ /dev/null@@ -1,6 +0,0 @@-en:- new_key: new_key- dashboard:- problem:- foo: foo- bar: bardiff --git a/spec/support/locales/message_builder.en.yml b/spec/support/locales/message_builder.en.ymldeleted file mode 100644index 628f94d8357..00000000000--- a/spec/support/locales/message_builder.en.yml+++ /dev/null@@ -1,2 +0,0 @@-en:- modified_visit_link_to_respond: modified_visit_link_to_responddiff --git a/spec/support/locales/problem_check.en.yml b/spec/support/locales/problem_check.en.ymldeleted file mode 100644index 07898c9a3a8..00000000000--- a/spec/support/locales/problem_check.en.yml+++ /dev/null@@ -1,2 +0,0 @@-en:- failing_check: failing_check