From 8efa112ca625cf8e895ed5af1433dce430929970 Mon Sep 17 00:00:00 2001 From: Tsukuru Tanimichi Date: Mon, 7 May 2018 17:25:01 +0900 Subject: Don't generate `config/spring.rb` in `app:update` task when spring isn't loaded --- railties/CHANGELOG.md | 6 +++++- railties/lib/rails/app_updater.rb | 1 + railties/test/generators/app_generator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 5d5ab61ef2..cf780940d1 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,4 +1,8 @@ -* Don't generate assets' initializer in `app:update` task if sprockets is skipped +* Don't generate unused files in `app:update` task + + Skip the assets' initializer when sprockets isn't loaded. + + Skip `config/spring.rb` when spring isn't loaded. *Tsukuru Tanimichi* diff --git a/railties/lib/rails/app_updater.rb b/railties/lib/rails/app_updater.rb index 5e2ea93c5e..e37839bf11 100644 --- a/railties/lib/rails/app_updater.rb +++ b/railties/lib/rails/app_updater.rb @@ -28,6 +28,7 @@ module Rails options[:skip_sprockets] = !defined?(Sprockets::Railtie) options[:skip_puma] = !defined?(Puma) options[:skip_bootsnap] = !defined?(Bootsnap) + options[:skip_spring] = !defined?(Spring) options end end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index bcfbcdfd80..f73747208b 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -309,6 +309,17 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_app_update_does_not_generate_spring_contents_when_skip_spring_is_given + app_root = File.join(destination_root, "myapp") + run_generator [app_root, "--skip-spring"] + + FileUtils.cd(app_root) do + quietly { system("bin/rails app:update") } + end + + assert_no_file "#{app_root}/config/spring.rb" + end + def test_app_update_does_not_generate_action_cable_contents_when_skip_action_cable_is_given app_root = File.join(destination_root, "myapp") run_generator [app_root, "--skip-action-cable"] -- cgit v1.2.3