aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorTsukuru Tanimichi <info+git@ttanimichi.com>2018-05-01 23:08:31 +0900
committerTsukuru Tanimichi <info+git@ttanimichi.com>2018-05-05 13:27:55 +0900
commit59c3d539ab9d3c00d910939f63eaadb67aea719b (patch)
tree9c163e3f9d63a68b88f72eb7f4b78608895a0b4c /railties/test
parenta42fb70a152ee05725685a8f68e3e8e2ddda4b36 (diff)
downloadrails-59c3d539ab9d3c00d910939f63eaadb67aea719b.tar.gz
rails-59c3d539ab9d3c00d910939f63eaadb67aea719b.tar.bz2
rails-59c3d539ab9d3c00d910939f63eaadb67aea719b.zip
Don't generate assets' initializer in `app:update` task if sprockets is skipped
Execute `rails new myapp -S` and then upgrade the app by using the `app:update` task, `bin/rails c` results in `NoMethodError`. ``` $ bin/rails app:update $ bin/rails c Traceback (most recent call last): 44: from bin/rails:4:in `<main>' (snip) 1: from /Users/tanimichi.tsukuru/ghq/github.com/moneyforward/moneyplus/config/initializers/assets.rb:4:in `<top (required)>' /Users/tanimichi.tsukuru/ghq/github.com/moneyforward/moneyplus/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie/configuration.rb:97:in `method_missing': undefined method `assets' for #<Rails::Application::Configuration:0x00007fcb8d3697e0> (NoMethodError) Did you mean? asset_host ```
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/app_generator_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index fa7bcfd6d6..938d545219 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -296,6 +296,19 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_app_update_does_not_generate_assets_initializer_when_skip_sprockets_is_given
+ app_root = File.join(destination_root, "myapp")
+ run_generator [app_root, "--skip-sprockets"]
+
+ stub_rails_application(app_root) do
+ generator = Rails::Generators::AppGenerator.new ["rails"], { update: true, skip_sprockets: true }, { destination_root: app_root, shell: @shell }
+ generator.send(:app_const)
+ quietly { generator.send(:update_config_files) }
+
+ assert_no_file "#{app_root}/config/initializers/assets.rb"
+ end
+ 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"]