From a7adec9336bca1fed9684f36acdd53ea231ce4b7 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Fri, 3 Jun 2016 09:40:42 -0400 Subject: 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`. --- railties/test/generators/app_generator_test.rb | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'railties/test/generators') 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 -- cgit v1.2.3