提交 9ea8de33 编写于 作者: P Prathamesh Sonpatki

Old applications will not get the ssl_options initializer

- We will remove the initializer for old apps which are migrated to
  Rails 5 so that they are not affected by this breaking change.
上级 00c4ecf3
......@@ -92,6 +92,7 @@ def config_when_updating
callback_terminator_config_exist = File.exist?('config/initializers/callback_terminator.rb')
active_record_belongs_to_required_by_default_config_exist = File.exist?('config/initializers/active_record_belongs_to_required_by_default.rb')
action_cable_config_exist = File.exist?('config/cable.yml')
ssl_options_exist = File.exist?('config/initializers/ssl_options.rb')
config
......@@ -110,6 +111,10 @@ def config_when_updating
unless action_cable_config_exist
template 'config/cable.yml'
end
unless ssl_options_exist
remove_file 'config/initializers/ssl_options.rb'
end
end
def database_yml
......
......@@ -241,6 +241,34 @@ def test_rails_update_does_not_remove_active_record_belongs_to_required_by_defau
end
end
def test_rails_update_does_not_create_ssl_options_by_default
app_root = File.join(destination_root, 'myapp')
run_generator [app_root]
FileUtils.rm("#{app_root}/config/initializers/ssl_options.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_no_file "#{app_root}/config/initializers/ssl_options.rb"
end
end
def test_rails_update_does_not_remove_ssl_options_if_already_present
app_root = File.join(destination_root, 'myapp')
run_generator [app_root]
FileUtils.touch("#{app_root}/config/initializers/ssl_options.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/ssl_options.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!/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册