From 7bb52d27813c33e967b8de2fe7889f3be236ac25 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sun, 1 Jan 2017 15:16:39 +0530 Subject: Remove bin/yarn if yarn is skipped, tidy up tests - No need to remove bin/yarn separately for API only apps because :skip_yarn is set to true for API only apps. - Added a test for :skip_yarn config. --- railties/lib/rails/generators/rails/app/app_generator.rb | 4 ++-- railties/test/generators/app_generator_test.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index eb66b0b16a..8efdfdcb44 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -350,8 +350,8 @@ module Rails end end - def delete_bin_yarn_if_api_option - remove_file "bin/yarn" if options[:api] + def delete_bin_yarn_if_skip_yarn_option + remove_file "bin/yarn" if options[:skip_yarn] end def finish_template diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 079ee3765c..20de2258c5 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -419,6 +419,13 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_generator_if_skip_yarn_is_given + run_generator [destination_root, "--skip-yarn"] + + assert_no_file "vendor/package.json" + assert_no_file "bin/yarn" + end + def test_generator_if_skip_action_cable_is_given run_generator [destination_root, "--skip-action-cable"] assert_file "config/application.rb", /#\s+require\s+["']action_cable\/engine["']/ -- cgit v1.2.3