diff options
author | Tsukuru Tanimichi <info+git@ttanimichi.com> | 2018-05-01 23:08:31 +0900 |
---|---|---|
committer | Tsukuru Tanimichi <info+git@ttanimichi.com> | 2018-05-05 13:27:55 +0900 |
commit | 59c3d539ab9d3c00d910939f63eaadb67aea719b (patch) | |
tree | 9c163e3f9d63a68b88f72eb7f4b78608895a0b4c /railties | |
parent | a42fb70a152ee05725685a8f68e3e8e2ddda4b36 (diff) | |
download | rails-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')
-rw-r--r-- | railties/CHANGELOG.md | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/tasks/framework.rake | 2 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 13 |
4 files changed, 22 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index a4d4a87a8b..5d5ab61ef2 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Don't generate assets' initializer in `app:update` task if sprockets is skipped + + *Tsukuru Tanimichi* + * Make the master.key file read-only for the owner upon generation on POSIX-compliant systems. diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 395ac7ef2f..bf086e0e0d 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -146,6 +146,10 @@ module Rails template "config/storage.yml" end + if options[:skip_sprockets] && !assets_config_exist + remove_file "config/initializers/assets.rb" + end + unless rack_cors_config_exist remove_file "config/initializers/cors.rb" end diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index 7dfcd14bd0..1a3711c446 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -40,7 +40,7 @@ namespace :app do namespace :update do require "rails/app_updater" - # desc "Update config/boot.rb from your current rails install" + # desc "Update config files from your current rails install" task :configs do Rails::AppUpdater.invoke_from_app_generator :create_boot_file Rails::AppUpdater.invoke_from_app_generator :update_config_files 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"] |