diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index ea9f9f5322..f4f2724ba6 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Skip Active Storage and Action Mailer if Active Job is skipped. + + *Étienne Barrié* + * Correctly check if frameworks are disabled when running app:update. *Étienne Barrié* and *Paulo Barros* diff --git a/railties/lib/rails/app_updater.rb b/railties/lib/rails/app_updater.rb index 9ddaec0503..b7ffea139b 100644 --- a/railties/lib/rails/app_updater.rb +++ b/railties/lib/rails/app_updater.rb @@ -23,7 +23,7 @@ module Rails options = { api: !!Rails.application.config.api_only, update: true } options[:skip_active_job] = !defined?(ActiveJob::Railtie) options[:skip_active_record] = !defined?(ActiveRecord::Railtie) - options[:skip_active_storage] = !defined?(ActiveStorage::Engine) || !defined?(ActiveRecord::Railtie) + options[:skip_active_storage] = !defined?(ActiveStorage::Engine) options[:skip_action_mailer] = !defined?(ActionMailer::Railtie) options[:skip_action_mailbox] = !defined?(ActionMailbox::Engine) options[:skip_action_text] = !defined?(ActionText::Engine) diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 922ff76c0e..6cb3f18023 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -190,12 +190,12 @@ module Rails [ options.values_at( :skip_active_record, - :skip_action_mailer, :skip_test, :skip_action_cable, :skip_active_job ), skip_active_storage?, + skip_action_mailer?, skip_action_mailbox?, skip_action_text? ].flatten.none? @@ -223,7 +223,11 @@ module Rails end def skip_active_storage? # :doc: - options[:skip_active_storage] || options[:skip_active_record] + options[:skip_active_storage] || options[:skip_active_record] || options[:skip_active_job] + end + + def skip_action_mailer? # :doc: + options[:skip_action_mailer] || options[:skip_active_job] end def skip_action_mailbox? # :doc: diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 256f8f48b7..d5acc91c28 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -292,12 +292,12 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_app_update_preserves_skip_active_job app_root = File.join(destination_root, "myapp") - run_generator [ app_root, "--skip-active-job", "--skip-active-storage", "--skip-action-mailer" ] + run_generator [ app_root, "--skip-active-job" ] FileUtils.cd(app_root) do config = "config/application.rb" assert_no_changes -> { File.readlines(config).grep(/require /) } do - system("yes | TEST=hi bin/rails app:update") + quietly { system("yes | bin/rails app:update") } end end end @@ -599,6 +599,8 @@ class AppGeneratorTest < Rails::Generators::TestCase end assert_file "config/application.rb" do |content| assert_match(/#\s+require\s+["']active_job\/railtie["']/, content) + assert_match(/#\s+require\s+["']active_storage\/engine["']/, content) + assert_match(/#\s+require\s+["']action_mailer\/railtie["']/, content) end end