diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-06-03 09:40:42 -0400 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-06-04 11:03:04 -0400 |
commit | a7adec9336bca1fed9684f36acdd53ea231ce4b7 (patch) | |
tree | 8dd21946c12903552892f88bf09b8016af805045 /railties/test | |
parent | b362ef9cb54a21fe23eda82539097a59c61af607 (diff) | |
download | rails-a7adec9336bca1fed9684f36acdd53ea231ce4b7.tar.gz rails-a7adec9336bca1fed9684f36acdd53ea231ce4b7.tar.bz2 rails-a7adec9336bca1fed9684f36acdd53ea231ce4b7.zip |
Fix minor regression about old apps not getting per_form_csrf and request_forgery_protection configs
- Earlier per_form_csrf_tokens and request_forgery_protection config
files were generated for old apps upgraded to Rails 5.
- But when we collapsed all initializers into one file, the entire file
does not get created for old apps.
- This commit fixes it and also changes values for all new defaults for
old apps so that they will not break.
- Also added a test for `rails app:update`.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index bea8db087f..d9d4b78a45 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -208,24 +208,13 @@ class AppGeneratorTest < Rails::Generators::TestCase FileUtils.rm("#{app_root}/config/initializers/new_framework_defaults.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell - generator.send(:app_const) - quietly { generator.send(:update_config_files) } - assert_no_file "#{app_root}/config/initializers/new_framework_defaults.rb" - end - end - - def test_rails_update_does_not_new_framework_defaults_if_already_present - app_root = File.join(destination_root, 'myapp') - run_generator [app_root] - - FileUtils.touch("#{app_root}/config/initializers/new_framework_defaults.rb") + quietly { `FORCE=true bin/rails app:update` } - stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell - generator.send(:app_const) - quietly { generator.send(:update_config_files) } - assert_file "#{app_root}/config/initializers/new_framework_defaults.rb" + assert_file "#{app_root}/config/initializers/new_framework_defaults.rb" do |content| + assert_match(/ActiveSupport\.halt_callback_chains_on_return_false = true/, content) + assert_match(/Rails\.application\.config.active_record\.belongs_to_required_by_default = false/, content) + assert_no_match(/Rails\.application\.config\.ssl_options/, content) + end end end |