Revert "DEV: Upgrade Rails to version 7.1" (#27625)
This reverts commit ce00f83173
.
This commit is contained in:
parent
099cf71bcc
commit
f58b844f45
|
@ -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:
|
||||
|
|
14
Gemfile
14
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"
|
||||
|
|
103
Gemfile.lock
103
Gemfile.lock
|
@ -1,54 +1,45 @@
|
|||
GEM
|
||||
remote: 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-imap
|
||||
net-pop
|
||||
net-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)
|
||||
drb
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
mutex_m
|
||||
tzinfo (~> 2.0)
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
|
@ -185,10 +176,6 @@ GEM
|
|||
progress (~> 3.0, >= 3.0.1)
|
||||
image_size (3.4.0)
|
||||
in_threads (1.6.0)
|
||||
io-console (0.7.2)
|
||||
irb (1.13.2)
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
iso8601 (0.13.0)
|
||||
jmespath (1.6.2)
|
||||
json (2.7.2)
|
||||
|
@ -335,8 +322,6 @@ GEM
|
|||
pry-stack_explorer (0.6.1)
|
||||
binding_of_caller (~> 1.0)
|
||||
pry (~> 0.13)
|
||||
psych (5.1.2)
|
||||
stringio
|
||||
public_suffix (6.0.0)
|
||||
puma (6.4.2)
|
||||
nio4r (~> 2.0)
|
||||
|
@ -347,13 +332,8 @@ GEM
|
|||
rack-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)
|
||||
webrick
|
||||
rails-dom-testing (2.2.0)
|
||||
activesupport (>= 5.0.0)
|
||||
minitest
|
||||
|
@ -368,14 +348,13 @@ GEM
|
|||
rails_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_source
|
||||
rake (>= 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)
|
||||
|
@ -387,15 +366,11 @@ GEM
|
|||
msgpack (>= 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.9)
|
||||
io-console (~> 0.5)
|
||||
request_store (1.7.0)
|
||||
rack (>= 1.4)
|
||||
rexml (3.3.1)
|
||||
|
@ -535,7 +510,6 @@ GEM
|
|||
sqlite3 (1.7.3-x86_64-linux)
|
||||
sshkey (3.0.0)
|
||||
stackprof (0.2.26)
|
||||
stringio (3.1.1)
|
||||
strscan (3.1.0)
|
||||
syntax_tree (6.2.0)
|
||||
prettier_print (>= 1.2.0)
|
||||
|
@ -566,7 +540,6 @@ GEM
|
|||
addressable (>= 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)
|
||||
|
@ -588,14 +561,14 @@ PLATFORMS
|
|||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
actionmailer (~> 7.1.0)
|
||||
actionpack (~> 7.1.0)
|
||||
actionview (~> 7.1.0)
|
||||
actionmailer (< 7.1)
|
||||
actionpack (< 7.1)
|
||||
actionview (< 7.1)
|
||||
actionview_precompiler
|
||||
active_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)
|
||||
addressable
|
||||
annotate
|
||||
aws-sdk-s3
|
||||
|
@ -683,7 +656,7 @@ DEPENDENCIES
|
|||
rails-dom-testing
|
||||
rails_failover
|
||||
rails_multisite
|
||||
railties (~> 7.1.0)
|
||||
railties (< 7.1)
|
||||
rake
|
||||
rb-fsevent
|
||||
rbtrace
|
||||
|
|
|
@ -4,7 +4,7 @@ class PostRevision < ActiveRecord::Base
|
|||
belongs_to :post
|
||||
belongs_to :user
|
||||
|
||||
serialize :modifications, type: Hash
|
||||
serialize :modifications, Hash
|
||||
|
||||
after_create :create_notification
|
||||
|
||||
|
|
|
@ -33,12 +33,8 @@ class Reviewable < ActiveRecord::Base
|
|||
has_many :reviewable_scores, -> { order(created_at: :desc) }, dependent: :destroy
|
||||
|
||||
enum :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, :integer
|
||||
enum :priority, { low: 0, medium: 5, high: 10 }, scopes: false, suffix: true
|
||||
enum :sensitivity, { disabled: 0, low: 9, medium: 6, high: 3 }, scopes: false, suffix: true
|
||||
|
||||
validates :reject_reason, length: { maximum: 2000 }
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ class TranslationOverride < ActiveRecord::Base
|
|||
|
||||
validate :check_interpolation_keys
|
||||
|
||||
attribute :status, :integer
|
||||
enum status: { up_to_date: 0, outdated: 1, invalid_interpolation_keys: 2, deprecated: 3 }
|
||||
|
||||
def self.upsert!(locale, key, value)
|
||||
|
|
|
@ -158,9 +158,7 @@ class User < ActiveRecord::Base
|
|||
unless: :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_level
|
||||
|
||||
|
|
|
@ -549,7 +549,7 @@ class StaffActionLogger
|
|||
|
||||
changed_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],
|
||||
)
|
||||
|
|
|
@ -90,7 +90,7 @@ module Discourse
|
|||
# tiny file needed by site settings
|
||||
require "highlight_js"
|
||||
|
||||
config.load_defaults 7.0
|
||||
config.load_defaults 6.1
|
||||
config.active_record.cache_versioning = false # our custom cache class doesn’t support this
|
||||
config.action_controller.forgery_protection_origin_check = false
|
||||
config.active_record.belongs_to_required_by_default = false
|
||||
|
@ -100,9 +100,6 @@ module Discourse
|
|||
Time,
|
||||
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 Discourse
|
|||
ENV["DISCOURSE_MULTISITE_CONFIG_PATH"] || GlobalSetting.multisite_config_path
|
||||
config.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 connect
|
||||
ActiveRecord::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
|
||||
end
|
||||
end
|
||||
|
||||
require "rbtrace" if ENV["RBTRACE"] == "1"
|
||||
|
|
|
@ -99,11 +99,4 @@ Discourse::Application.configure do
|
|||
end
|
||||
|
||||
config.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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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 environment
|
||||
config.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 do
|
||||
ActiveRecord::LogSubscriber.backtrace_cleaner.add_silencer do |line|
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
# Multisite freedom patch defines RailsMultisite::DiscoursePatches.config which is used by 200-first_middlewares.rb
|
||||
# Therefore it can not be postponed with .to_prepare
|
||||
RUN_WITHOUT_PREPARE = [
|
||||
"#{Rails.root}/lib/freedom_patches/rails_multisite.rb",
|
||||
"#{Rails.root}/lib/freedom_patches/rails_rack_logger_from_rails_7_2.rb",
|
||||
]
|
||||
RUN_WITHOUT_PREPARE = ["#{Rails.root}/lib/freedom_patches/rails_multisite.rb"]
|
||||
RUN_WITHOUT_PREPARE.each { |path| require(path) }
|
||||
|
||||
Rails.application.reloader.to_prepare do
|
||||
|
|
|
@ -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? :chained
|
||||
end
|
||||
|
||||
if defined?(RailsFailover::ActiveRecord)
|
||||
|
|
|
@ -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? :chained
|
||||
end
|
||||
return
|
||||
end
|
||||
|
@ -10,12 +10,12 @@ end
|
|||
if Rails.env.development? && !Sidekiq.server? && ENV["RAILS_LOGS_STDOUT"] == "1"
|
||||
Rails.application.config.after_initialize do
|
||||
console = ActiveSupport::Logger.new(STDOUT)
|
||||
original_logger = Rails.logger.broadcasts.first
|
||||
original_logger = Rails.logger.chained.first
|
||||
console.formatter = original_logger.formatter
|
||||
console.level = original_logger.level
|
||||
|
||||
unless ActiveSupport::Logger.logger_outputs_to?(original_logger, STDOUT)
|
||||
Rails.logger.broadcast_to(console)
|
||||
original_logger.extend(ActiveSupport::Logger.broadcast(console))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -118,7 +118,10 @@ RailsMultisite::ConnectionManagement.each_connection do
|
|||
end
|
||||
|
||||
if 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
|
||||
end
|
||||
end
|
||||
|
||||
Logster.config.project_directories = [
|
||||
|
|
|
@ -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.logger
|
||||
override = true
|
||||
Logster.logger.override_level = Logger::ERROR
|
||||
Rails.logger.override_level = Logger::ERROR
|
||||
end
|
||||
end
|
||||
|
||||
super(env).tap { Logster.logger.override_level = nil if override }
|
||||
super(env).tap { Rails.logger.override_level = nil if override }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,16 +20,16 @@ class SilenceLogger < Rails::Rack::Logger
|
|||
if 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.logger
|
||||
override = true
|
||||
Logster.logger.override_level = Logger::WARN
|
||||
Rails.logger.override_level = Logger::WARN
|
||||
end
|
||||
@app.call(env)
|
||||
else
|
||||
super
|
||||
super(env)
|
||||
end
|
||||
ensure
|
||||
Logster.logger.override_level = nil if override
|
||||
Rails.logger.override_level = nil if override
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ Rails.application.config.to_prepare do
|
|||
require "lograge"
|
||||
|
||||
if Rails.configuration.multisite
|
||||
Rails.logger.formatter =
|
||||
ActiveSupport::Logger::SimpleFormatter.new.extend(ActiveSupport::TaggedLogging::Formatter)
|
||||
Rails.logger.formatter = ActiveSupport::Logger::SimpleFormatter.new
|
||||
end
|
||||
|
||||
Rails.application.configure do
|
||||
|
@ -112,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.first)
|
||||
Rails.logger.broadcast_to(config.lograge.logger)
|
||||
Rails.logger.chained.pop
|
||||
Rails.logger.chain(config.lograge.logger)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,10 @@ if Rails.env.production? || ENV["ENABLE_LOGS_TRUNCATION"] == "1"
|
|||
end
|
||||
|
||||
Rails.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) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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",
|
||||
}
|
|
@ -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 = :html5
|
|
@ -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:
|
||||
|
|
|
@ -954,7 +954,14 @@ module Discourse
|
|||
def 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 = env
|
||||
|
||||
if old_env = Thread.current[Logster::Logger::LOGSTER_ENV]
|
||||
|
@ -1109,7 +1116,16 @@ module Discourse
|
|||
end
|
||||
end
|
||||
|
||||
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_cache
|
||||
I18n.t(:posts)
|
||||
|
||||
# this will force Cppjieba to preload if any site has it
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# TODO: Drop this patch when upgrading to Rails 7.2
|
||||
#
|
||||
# Here we use the code from Rails 7.2 because the code from Rails 7.1 has a
|
||||
# nasty bug that happens when there is more than one tagged logger in the
|
||||
# broadcast logger.
|
||||
# The Rails 7.1 implementation calls `#call_app` as many times as there are
|
||||
# tagged loggers, which leads to all sort of strange behaviors.
|
||||
module RailsRackLoggerFromRails7_2
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def call(env)
|
||||
request = ActionDispatch::Request.new(env)
|
||||
|
||||
env["rails.rack_logger_tag_count"] = if logger.respond_to?(:push_tags)
|
||||
logger.push_tags(*compute_tags(request)).size
|
||||
else
|
||||
0
|
||||
end
|
||||
|
||||
call_app(request, env)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def call_app(request, env) # :doc:
|
||||
logger_tag_pop_count = env["rails.rack_logger_tag_count"]
|
||||
|
||||
instrumenter = ActiveSupport::Notifications.instrumenter
|
||||
handle = instrumenter.build_handle("request.action_dispatch", { request: request })
|
||||
handle.start
|
||||
|
||||
logger.info { started_request_message(request) }
|
||||
status, headers, body = response = @app.call(env)
|
||||
body =
|
||||
::Rack::BodyProxy.new(body) { finish_request_instrumentation(handle, logger_tag_pop_count) }
|
||||
|
||||
if response.frozen?
|
||||
[status, headers, body]
|
||||
else
|
||||
response[2] = body
|
||||
response
|
||||
end
|
||||
rescue Exception
|
||||
finish_request_instrumentation(handle, logger_tag_pop_count)
|
||||
raise
|
||||
end
|
||||
|
||||
def finish_request_instrumentation(handle, logger_tag_pop_count)
|
||||
handle.finish
|
||||
if logger.respond_to?(:pop_tags) && logger_tag_pop_count > 0
|
||||
logger.pop_tags(logger_tag_pop_count)
|
||||
end
|
||||
ActiveSupport::LogSubscriber.flush_all!
|
||||
end
|
||||
end
|
||||
Rails::Rack::Logger.prepend(RailsRackLoggerFromRails7_2)
|
|
@ -53,10 +53,10 @@ module Hijack
|
|||
# this trick avoids double render, also avoids any litter that the controller hooks
|
||||
# place on the response
|
||||
instance = 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_copy
|
||||
original_headers&.each { |k, v| instance.response.headers[k] = v }
|
||||
|
||||
view_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
||||
|
|
|
@ -34,7 +34,7 @@ module Middleware
|
|||
if exception
|
||||
begin
|
||||
fake_controller = ApplicationController.new
|
||||
fake_controller.set_response!(response)
|
||||
fake_controller.response = response
|
||||
fake_controller.request = request = ActionDispatch::Request.new(env)
|
||||
|
||||
# We can not re-dispatch bad mime types
|
||||
|
|
|
@ -274,7 +274,7 @@ module SiteSettingExtension
|
|||
end
|
||||
|
||||
def description(setting)
|
||||
I18n.t("site_settings.#{setting}", base_path: Discourse.base_path, default: "")
|
||||
I18n.t("site_settings.#{setting}", base_path: Discourse.base_path)
|
||||
end
|
||||
|
||||
def keywords(setting)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module Chat
|
||||
class CategoryChannel < Channel
|
||||
alias_method :category, :chatable
|
||||
alias_attribute :category, :chatable
|
||||
|
||||
delegate :read_restricted?, to: :category
|
||||
delegate :url, to: :chatable, prefix: true
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module Chat
|
||||
class DirectMessageChannel < Channel
|
||||
alias_method :direct_message, :chatable
|
||||
alias_attribute :direct_message, :chatable
|
||||
|
||||
def direct_message_channel?
|
||||
true
|
||||
|
|
|
@ -183,7 +183,7 @@ RSpec.describe "Visit channel", type: :system do
|
|||
context "when visiting a specific channel message ID then navigating to another channel" do
|
||||
fab!(: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)
|
||||
end
|
||||
fab!(:other_channel_message) { Fabricate(:chat_message, chat_channel: other_channel) }
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "invalid requests", type: :request do
|
||||
let(:fake_logger) { FakeLogger.new }
|
||||
before do
|
||||
@orig_logger = Rails.logger
|
||||
Rails.logger = @fake_logger = FakeLogger.new
|
||||
end
|
||||
|
||||
before { Rails.logger.broadcast_to(fake_logger) }
|
||||
|
||||
after { Rails.logger.stop_broadcasting_to(fake_logger) }
|
||||
after { Rails.logger = @orig_logger }
|
||||
|
||||
it "handles NotFound with invalid json body" do
|
||||
post "/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)
|
||||
end
|
||||
|
||||
it "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)
|
||||
end
|
||||
|
||||
it "handles invalid parameters" do
|
||||
post "/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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,11 +21,11 @@ RSpec.describe Auth::DefaultCurrentUserProvider do
|
|||
end
|
||||
|
||||
def 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 = {}
|
||||
|
|
|
@ -14,9 +14,9 @@ RSpec.describe Email::MessageBuilder do
|
|||
|
||||
let(: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" do
|
||||
expect(build_args[:to]).to eq(to_address)
|
||||
|
@ -69,7 +69,7 @@ RSpec.describe Email::MessageBuilder do
|
|||
include_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")
|
||||
ensure
|
||||
DiscoursePluginRegistry.unregister_modifier(
|
||||
plugin_instance,
|
||||
|
@ -93,7 +93,7 @@ RSpec.describe Email::MessageBuilder do
|
|||
url: "http://localhost",
|
||||
)
|
||||
expect(builder2.template_args[:respond_instructions]).to include(
|
||||
"modified_visit_link_to_respond",
|
||||
"modified visit_link_to_respond",
|
||||
)
|
||||
ensure
|
||||
DiscoursePluginRegistry.unregister_modifier(
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe Hijack do
|
|||
self.request = ActionController::TestRequest.new(env, nil, nil)
|
||||
|
||||
# we need this for the 418
|
||||
set_response!(ActionDispatch::Response.new)
|
||||
self.response = ActionDispatch::Response.new
|
||||
end
|
||||
|
||||
def hijack_test(&blk)
|
||||
|
@ -22,10 +22,12 @@ RSpec.describe Hijack do
|
|||
end
|
||||
end
|
||||
|
||||
let(:tester) { Hijack::Tester.new }
|
||||
let :tester do
|
||||
Hijack::Tester.new
|
||||
end
|
||||
|
||||
describe "Request Tracker integration" do
|
||||
let(:logger) do
|
||||
let :logger do
|
||||
lambda do |env, data|
|
||||
@calls += 1
|
||||
@status = data[:status]
|
||||
|
@ -179,7 +181,7 @@ RSpec.describe Hijack do
|
|||
end
|
||||
|
||||
result =
|
||||
"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)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,12 +9,11 @@ RSpec.describe Migration::SafeMigrate do
|
|||
end
|
||||
|
||||
def migrate_up(path)
|
||||
migrations = ActiveRecord::MigrationContext.new(path).migrations
|
||||
migrations = ActiveRecord::MigrationContext.new(path, ActiveRecord::SchemaMigration).migrations
|
||||
ActiveRecord::Migrator.new(
|
||||
:up,
|
||||
migrations,
|
||||
ActiveRecord::Base.connection.schema_migration,
|
||||
ActiveRecord::Base.connection.internal_metadata,
|
||||
ActiveRecord::SchemaMigration,
|
||||
migrations.first.version,
|
||||
).run
|
||||
end
|
||||
|
@ -78,7 +77,7 @@ RSpec.describe Migration::SafeMigrate do
|
|||
|
||||
output = 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)")
|
||||
end
|
||||
|
||||
it "supports being disabled" do
|
||||
|
|
|
@ -422,7 +422,9 @@ RSpec.describe SiteSettingExtension do
|
|||
end
|
||||
end
|
||||
|
||||
let(:test_enum_class) { TestEnumClass }
|
||||
let :test_enum_class do
|
||||
TestEnumClass
|
||||
end
|
||||
|
||||
before do
|
||||
settings.setting(:test_enum, "en", enum: test_enum_class)
|
||||
|
|
|
@ -42,7 +42,7 @@ RSpec.describe AdminDashboardData do
|
|||
end
|
||||
|
||||
describe "#problem_message_check" do
|
||||
let(:key) { "new_key" }
|
||||
let(:key) { AdminDashboardData.problem_messages.first }
|
||||
|
||||
after { described_class.clear_problem_message(key) }
|
||||
|
||||
|
|
|
@ -678,7 +678,7 @@ RSpec.describe User do
|
|||
quoted_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]
|
||||
|
|
|
@ -245,7 +245,7 @@ RSpec.configure do |config|
|
|||
CachedCounting.disable
|
||||
|
||||
begin
|
||||
ActiveRecord::Migration.check_all_pending!
|
||||
ActiveRecord::Migration.check_pending!
|
||||
rescue ActiveRecord::PendingMigrationError
|
||||
raise "There are pending migrations, run RAILS_ENV=test bin/rake db:migrate"
|
||||
end
|
||||
|
@ -718,7 +718,7 @@ RSpec.configure do |config|
|
|||
end
|
||||
|
||||
config.after(:each, type: :multisite) do
|
||||
ActiveRecord::Base.connection_handler.clear_all_connections!
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
Rails.configuration.multisite = false # rubocop:disable Discourse/NoDirectMultisiteManipulation
|
||||
RailsMultisite::ConnectionManagement.clear_settings!
|
||||
ActiveRecord::Base.establish_connection
|
||||
|
|
|
@ -326,7 +326,7 @@ RSpec.describe ApplicationController do
|
|||
|
||||
expect(log).not_to include("exception app middleware")
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(response.parsed_body).to eq("status" => 400, "error" => "Bad Request")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -39,16 +39,16 @@ RSpec.describe CategoriesController do
|
|||
|
||||
it "redirects /category paths to /c paths" do
|
||||
get "/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")
|
||||
end
|
||||
|
||||
it "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)
|
||||
end
|
||||
|
||||
it "returns the right response for a normal user" do
|
||||
|
|
|
@ -190,6 +190,8 @@ RSpec.describe EmbedController do
|
|||
context "with a host" do
|
||||
fab!(:embeddable_host)
|
||||
|
||||
before { Jobs.run_immediately! }
|
||||
|
||||
it "doesn't raise an error with no referer" do
|
||||
get "/embed/comments", params: { embed_url: embed_url }
|
||||
|
||||
|
@ -244,8 +246,6 @@ RSpec.describe EmbedController do
|
|||
end
|
||||
|
||||
context "with success" do
|
||||
before { Jobs.run_immediately! }
|
||||
|
||||
it "tells the topic retriever to work when no previous embed is found" do
|
||||
TopicRetriever.any_instance.expects(:retrieve)
|
||||
|
||||
|
|
|
@ -946,7 +946,7 @@ RSpec.describe SessionController do
|
|||
get "/session/sso_login", params: Rack::Utils.parse_query(sso.payload), headers: headers
|
||||
|
||||
expect(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 do
|
|||
login_with_sso_and_invite
|
||||
|
||||
expect(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("bob@bob.com")
|
||||
|
|
|
@ -8,13 +8,13 @@ RSpec.describe UploadsController, type: %i[multisite request] do
|
|||
setup_s3
|
||||
SiteSetting.secure_uploads = true
|
||||
upload.update(secure: true)
|
||||
sign_in(user)
|
||||
freeze_time
|
||||
end
|
||||
|
||||
it "redirects to the signed_url_for_path with the multisite DB name in the url" do
|
||||
sign_in(user)
|
||||
freeze_time
|
||||
get upload.short_path
|
||||
|
||||
expect(response).to redirect_to(/#{RailsMultisite::ConnectionManagement.current_db}/)
|
||||
expect(response.body).to include(RailsMultisite::ConnectionManagement.current_db)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FakeLogger
|
||||
attr_reader :debugs, :infos, :warnings, :errors, :fatals, :severities
|
||||
attr_reader :debugs, :infos, :warnings, :errors, :fatals
|
||||
attr_accessor :level
|
||||
|
||||
def 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 << message
|
||||
end
|
||||
|
||||
|
@ -30,7 +29,7 @@ class FakeLogger
|
|||
@level <= Logger::INFO
|
||||
end
|
||||
|
||||
def warn(message = nil)
|
||||
def warn(message)
|
||||
@warnings << message
|
||||
end
|
||||
|
||||
|
@ -38,7 +37,7 @@ class FakeLogger
|
|||
@level <= Logger::WARN
|
||||
end
|
||||
|
||||
def error(message = nil)
|
||||
def error(message)
|
||||
@errors << message
|
||||
end
|
||||
|
||||
|
@ -46,7 +45,7 @@ class FakeLogger
|
|||
@level <= Logger::ERROR
|
||||
end
|
||||
|
||||
def fatal(message = nil)
|
||||
def fatal(message)
|
||||
@fatals << message
|
||||
end
|
||||
|
||||
|
@ -56,12 +55,4 @@ class FakeLogger
|
|||
|
||||
def formatter
|
||||
end
|
||||
|
||||
def add(severity, message = nil, progname = nil)
|
||||
public_send(severities[severity]) << message
|
||||
end
|
||||
|
||||
def broadcasts
|
||||
[self]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
|
||||
module I18nHelpers
|
||||
def allow_missing_translations
|
||||
original_handler = I18n.exception_handler
|
||||
I18n.exception_handler = nil
|
||||
Rails.application.config.i18n.raise_on_missing_translations = false
|
||||
yield
|
||||
ensure
|
||||
I18n.exception_handler = original_handler
|
||||
Rails.application.config.i18n.raise_on_missing_translations = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
en:
|
||||
new_key: new_key
|
||||
dashboard:
|
||||
problem:
|
||||
foo: foo
|
||||
bar: bar
|
|
@ -1,2 +0,0 @@
|
|||
en:
|
||||
modified_visit_link_to_respond: modified_visit_link_to_respond
|
|
@ -1,2 +0,0 @@
|
|||
en:
|
||||
failing_check: failing_check
|
Loading…
Reference in New Issue