1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove cors initializer from rails app

`rack-cors` gem is defined in Gemfile by default only if the api,
not defined by default in rails app.
This commit is contained in:
yuuji.yaginuma 2015-12-22 18:39:08 +09:00
parent aa96537d37
commit 9917c0c255
2 changed files with 12 additions and 0 deletions

View file

@ -329,6 +329,12 @@ module Rails
end
end
def delete_api_initializers
unless options[:api]
remove_file 'config/initializers/cors.rb'
end
end
def finish_template
build(:leftovers)
end

View file

@ -151,6 +151,12 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_file("config/initializers/cookies_serializer.rb", /Rails\.application\.config\.action_dispatch\.cookies_serializer = :json/)
end
def test_new_application_not_include_api_initializers
run_generator
assert_no_file 'config/initializers/cors.rb'
end
def test_rails_update_keep_the_cookie_serializer_if_it_is_already_configured
app_root = File.join(destination_root, 'myapp')
run_generator [app_root]