diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 40874787fa..5fbd0e4338 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -31,7 +31,7 @@ module ActiveRecord config.active_record.maintain_test_schema = true config.active_record.has_many_inversing = false - config.active_record.queues = ActiveSupport::InheritableOptions.new(destroy: :active_record_destroy) + config.active_record.queues = ActiveSupport::InheritableOptions.new config.eager_load_namespaces << ActiveRecord diff --git a/activestorage/lib/active_storage/engine.rb b/activestorage/lib/active_storage/engine.rb index 2bdf191a7a..e2413c4538 100644 --- a/activestorage/lib/active_storage/engine.rb +++ b/activestorage/lib/active_storage/engine.rb @@ -26,7 +26,7 @@ module ActiveStorage config.active_storage.previewers = [ ActiveStorage::Previewer::PopplerPDFPreviewer, ActiveStorage::Previewer::MuPDFPreviewer, ActiveStorage::Previewer::VideoPreviewer ] config.active_storage.analyzers = [ ActiveStorage::Analyzer::ImageAnalyzer, ActiveStorage::Analyzer::VideoAnalyzer ] config.active_storage.paths = ActiveSupport::OrderedOptions.new - config.active_storage.queues = ActiveSupport::InheritableOptions.new(mirror: :active_storage_mirror) + config.active_storage.queues = ActiveSupport::InheritableOptions.new config.active_storage.variable_content_types = %w( image/png diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 496fb10ed3..ec7a353bb2 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -473,7 +473,7 @@ in controllers and views. This defaults to `false`. * `config.active_record.destroy_association_async_job` allows specifying the job that will be used to destroy the associated records in background. It defaults to `ActiveRecord::DestroyAssociationAsyncJob`. -* `config.active_record.queues.destroy` allows specifying the Active Job queue to use for destroy jobs. It defaults to `:active_record_destroy`. +* `config.active_record.queues.destroy` allows specifying the Active Job queue to use for destroy jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `nil`. The MySQL adapter adds one additional configuration option: @@ -725,9 +725,9 @@ Defaults to `'signed cookie'`. config.action_mailbox.incinerate_after = 14.days ``` -* `config.action_mailbox.queues.incineration` accepts a symbol indicating the Active Job queue to use for incineration jobs. It defaults to `:action_mailbox_incineration`. +* `config.action_mailbox.queues.incineration` accepts a symbol indicating the Active Job queue to use for incineration jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `:action_mailbox_incineration`. -* `config.action_mailbox.queues.routing` accepts a symbol indicating the Active Job queue to use for routing jobs. It defaults to `:action_mailbox_routing`. +* `config.action_mailbox.queues.routing` accepts a symbol indicating the Active Job queue to use for routing jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). It defaults to `:action_mailbox_routing`. ### Configuring Action Mailer @@ -956,19 +956,19 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla * `config.active_storage.content_types_allowed_inline` accepts an array of strings indicating the content types that Active Storage allows to serve as inline. The default is `%w(image/png image/gif image/jpg image/jpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon application/pdf)`. -* `config.active_storage.queues.analysis` accepts a symbol indicating the Active Job queue to use for analysis jobs. When this option is `nil`, analysis jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). +* `config.active_storage.queues.analysis` accepts a symbol indicating the Active Job queue to use for analysis jobs. When this option is `nil`, analysis jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). The default is `nil`. ```ruby config.active_storage.queues.analysis = :low_priority ``` -* `config.active_storage.queues.purge` accepts a symbol indicating the Active Job queue to use for purge jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). +* `config.active_storage.queues.purge` accepts a symbol indicating the Active Job queue to use for purge jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). The default is `nil`. ```ruby config.active_storage.queues.purge = :low_priority ``` -* `config.active_storage.queues.mirror` accepts a symbol indicating the Active Job queue to use for direct upload mirroring jobs. The default is `:active_storage_mirror`. +* `config.active_storage.queues.mirror` accepts a symbol indicating the Active Job queue to use for direct upload mirroring jobs. When this option is `nil`, purge jobs are sent to the default Active Job queue (see `config.active_job.default_queue_name`). The default is `nil`. ```ruby config.active_storage.queues.mirror = :low_priority @@ -1018,6 +1018,11 @@ text/javascript image/svg+xml application/postscript application/x-shockwave-fla - `config.active_record.has_many_inversing`: `true` - `config.active_record.legacy_connection_handling`: `false` - `config.active_storage.track_variants`: `true` +- `config.active_storage.queues.analysis`: `nil` +- `config.active_storage.queues.purge`: `nil` +- `config.action_mailbox.queues.incineration`: `nil` +- `config.action_mailbox.queues.routing`: `nil` +- `config.action_mailer.deliver_later_queue_name`: `nil` - `config.active_job.retry_jitter`: `0.15` - `config.active_job.skip_after_callbacks_if_terminated`: `true` - `config.action_dispatch.cookies_same_site_protection`: `:lax` diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index eab7a61d0c..268fc22e30 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -185,6 +185,20 @@ module Rails action_view.form_with_generates_remote_forms = false end + if respond_to?(:active_storage) + active_storage.queues.analysis = nil + active_storage.queues.purge = nil + end + + if respond_to?(:action_mailbox) + action_mailbox.queues.incineration = nil + action_mailbox.queues.routing = nil + end + + if respond_to?(:action_mailer) + action_mailer.deliver_later_queue_name = nil + end + ActiveSupport.utc_to_local_returns_utc_offset_times = true when "6.2" load_defaults "6.1" diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index b17913c077..a40765d4e9 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1149,6 +1149,29 @@ module ApplicationTests assert_equal "test_default", ActionMailer::Base.class_variable_get(:@@deliver_later_queue_name) end + test "ActionMailer::DeliveryJob queue name is :mailers without the Rails defaults" do + remove_from_config '.*config\.load_defaults.*\n' + + app "development" + + require "mail" + _ = ActionMailer::Base + + assert_equal :mailers, ActionMailer::Base.class_variable_get(:@@deliver_later_queue_name) + end + + test "ActionMailer::DeliveryJob queue name is nil by default in 6.1" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.1"' + + app "development" + + require "mail" + _ = ActionMailer::Base + + assert_nil ActionMailer::Base.class_variable_get(:@@deliver_later_queue_name) + end + test "valid timezone is setup correctly" do add_to_config <<-RUBY config.root = "#{app_path}" @@ -2449,12 +2472,24 @@ module ApplicationTests assert_equal true, ActiveSupport.utc_to_local_returns_utc_offset_times end - test "ActiveStorage.queues[:analysis] is :active_storage_analysis by default" do + test "ActiveStorage.queues[:analysis] is :active_storage_analysis by default in 6.0" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.0"' + app "development" assert_equal :active_storage_analysis, ActiveStorage.queues[:analysis] end + test "ActiveStorage.queues[:analysis] is nil by default in 6.1" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.1"' + + app "development" + + assert_nil ActiveStorage.queues[:analysis] + end + test "ActiveStorage.queues[:analysis] is nil without Rails 6 defaults" do remove_from_config '.*config\.load_defaults.*\n' @@ -2463,12 +2498,24 @@ module ApplicationTests assert_nil ActiveStorage.queues[:analysis] end - test "ActiveStorage.queues[:purge] is :active_storage_purge by default" do + test "ActiveStorage.queues[:purge] is :active_storage_purge by default in 6.0" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.0"' + app "development" assert_equal :active_storage_purge, ActiveStorage.queues[:purge] end + test "ActiveStorage.queues[:purge] is nil by default in 6.1" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.1"' + + app "development" + + assert_nil ActiveStorage.queues[:purge] + end + test "ActiveStorage.queues[:purge] is nil without Rails 6 defaults" do remove_from_config '.*config\.load_defaults.*\n' @@ -2477,6 +2524,20 @@ module ApplicationTests assert_nil ActiveStorage.queues[:purge] end + test "ActiveStorage.queues[:mirror] is nil without Rails 6 defaults" do + remove_from_config '.*config\.load_defaults.*\n' + + app "development" + + assert_nil ActiveStorage.queues[:mirror] + end + + test "ActiveStorage.queues[:mirror] is nil by default" do + app "development" + + assert_nil ActiveStorage.queues[:mirror] + end + test "ActionCable.server.config.cable is set when missing configuration for the current environment" do quietly do app "missing" @@ -2524,12 +2585,24 @@ module ApplicationTests assert_equal 14.days, ActionMailbox.incinerate_after end - test "ActionMailbox.queues[:incineration] is :action_mailbox_incineration by default" do + test "ActionMailbox.queues[:incineration] is :action_mailbox_incineration by default in 6.0" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.0"' + app "development" assert_equal :action_mailbox_incineration, ActionMailbox.queues[:incineration] end + test "ActionMailbox.queues[:incineration] is nil by default in 6.1" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.1"' + + app "development" + + assert_nil ActionMailbox.queues[:incineration] + end + test "ActionMailbox.queues[:incineration] can be configured" do add_to_config <<-RUBY config.action_mailbox.queues.incineration = :another_queue @@ -2540,12 +2613,24 @@ module ApplicationTests assert_equal :another_queue, ActionMailbox.queues[:incineration] end - test "ActionMailbox.queues[:routing] is :action_mailbox_routing by default" do + test "ActionMailbox.queues[:routing] is :action_mailbox_routing by default in 6.0" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.0"' + app "development" assert_equal :action_mailbox_routing, ActionMailbox.queues[:routing] end + test "ActionMailbox.queues[:routing] is nil by default in 6.1" do + remove_from_config '.*config\.load_defaults.*\n' + add_to_config 'config.load_defaults "6.1"' + + app "development" + + assert_nil ActionMailbox.queues[:routing] + end + test "ActionMailbox.queues[:routing] can be configured" do add_to_config <<-RUBY config.action_mailbox.queues.routing = :another_queue