aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-02-27 11:48:52 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-02-27 11:48:52 +0900
commit5a9cc012a0b2c8bc059abb8f5663f0c66258583c (patch)
tree43cf3a942c808f24ced3ef45aecc6e0f54c64b3a /railties/test/generators
parentbf1ac69636f6dabfd993afd4ad29416514816daf (diff)
downloadrails-5a9cc012a0b2c8bc059abb8f5663f0c66258583c.tar.gz
rails-5a9cc012a0b2c8bc059abb8f5663f0c66258583c.tar.bz2
rails-5a9cc012a0b2c8bc059abb8f5663f0c66258583c.zip
remove rack cors initializer when updating
Rack cors initializer is only necessary to API-only applications, for when the update is unnecessary.
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/app_generator_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index c5f9e11ad3..63655044da 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -269,6 +269,32 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_rails_update_does_not_create_rack_cors
+ app_root = File.join(destination_root, 'myapp')
+ run_generator [app_root]
+
+ stub_rails_application(app_root) do
+ generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell
+ generator.send(:app_const)
+ quietly { generator.send(:update_config_files) }
+ assert_no_file "#{app_root}/config/initializers/cors.rb"
+ end
+ end
+
+ def test_rails_update_does_not_remove_rack_cors_if_already_present
+ app_root = File.join(destination_root, 'myapp')
+ run_generator [app_root]
+
+ FileUtils.touch("#{app_root}/config/initializers/cors.rb")
+
+ stub_rails_application(app_root) do
+ generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell
+ generator.send(:app_const)
+ quietly { generator.send(:update_config_files) }
+ assert_file "#{app_root}/config/initializers/cors.rb"
+ end
+ end
+
def test_application_names_are_not_singularized
run_generator [File.join(destination_root, "hats")]
assert_file "hats/config/environment.rb", /Rails\.application\.initialize!/