@@ -269,6 +269,32 @@ def test_rails_update_does_not_remove_ssl_options_if_already_present
269
269
end
270
270
end
271
271
272
+ def test_rails_update_does_not_create_rack_cors
273
+ app_root = File . join ( destination_root , 'myapp' )
274
+ run_generator [ app_root ]
275
+
276
+ stub_rails_application ( app_root ) do
277
+ generator = Rails ::Generators ::AppGenerator . new [ "rails" ] , { with_dispatchers : true } , destination_root : app_root , shell : @shell
278
+ generator . send ( :app_const )
279
+ quietly { generator . send ( :update_config_files ) }
280
+ assert_no_file "#{ app_root } /config/initializers/cors.rb"
281
+ end
282
+ end
283
+
284
+ def test_rails_update_does_not_remove_rack_cors_if_already_present
285
+ app_root = File . join ( destination_root , 'myapp' )
286
+ run_generator [ app_root ]
287
+
288
+ FileUtils . touch ( "#{ app_root } /config/initializers/cors.rb" )
289
+
290
+ stub_rails_application ( app_root ) do
291
+ generator = Rails ::Generators ::AppGenerator . new [ "rails" ] , { with_dispatchers : true } , destination_root : app_root , shell : @shell
292
+ generator . send ( :app_const )
293
+ quietly { generator . send ( :update_config_files ) }
294
+ assert_file "#{ app_root } /config/initializers/cors.rb"
295
+ end
296
+ end
297
+
272
298
def test_application_names_are_not_singularized
273
299
run_generator [ File . join ( destination_root , "hats" ) ]
274
300
assert_file "hats/config/environment.rb" , /Rails\. application\. initialize!/
0 commit comments