diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-12-12 23:04:27 +0000 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-12-12 23:31:25 +0000 |
commit | 1a411d4b7f34df2471a93517ad15cc2682bbdbe2 (patch) | |
tree | 1c13455a4fedad64b903629313bef52e2f8fb141 /activerecord/test/cases/tasks | |
parent | 9d43a84f73c1b3853a91d052a462ee60eccaf957 (diff) | |
download | rails-1a411d4b7f34df2471a93517ad15cc2682bbdbe2.tar.gz rails-1a411d4b7f34df2471a93517ad15cc2682bbdbe2.tar.bz2 rails-1a411d4b7f34df2471a93517ad15cc2682bbdbe2.zip |
Convert protected_environments to an array of strings
These changes prevent ignoring environments name of which is a `Symbol`
```
config.active_record.protected_environments = ['staging', :production]
```
Diffstat (limited to 'activerecord/test/cases/tasks')
-rw-r--r-- | activerecord/test/cases/tasks/database_tasks_test.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/activerecord/test/cases/tasks/database_tasks_test.rb b/activerecord/test/cases/tasks/database_tasks_test.rb index 5a094ead42..fd381f229f 100644 --- a/activerecord/test/cases/tasks/database_tasks_test.rb +++ b/activerecord/test/cases/tasks/database_tasks_test.rb @@ -30,13 +30,30 @@ module ActiveRecord def test_raises_an_error_when_called_with_protected_environment ActiveRecord::Migrator.stubs(:current_version).returns(1) - protected_environments = ActiveRecord::Base.protected_environments.dup + protected_environments = ActiveRecord::Base.protected_environments current_env = ActiveRecord::Migrator.current_environment assert_not_includes protected_environments, current_env # Assert no error ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! - ActiveRecord::Base.protected_environments << current_env + ActiveRecord::Base.protected_environments = [current_env] + assert_raise(ActiveRecord::ProtectedEnvironmentError) do + ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! + end + ensure + ActiveRecord::Base.protected_environments = protected_environments + end + + def test_raises_an_error_when_called_with_protected_environment_which_name_is_a_symbol + ActiveRecord::Migrator.stubs(:current_version).returns(1) + + protected_environments = ActiveRecord::Base.protected_environments + current_env = ActiveRecord::Migrator.current_environment + assert_not_includes protected_environments, current_env + # Assert no error + ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! + + ActiveRecord::Base.protected_environments = [current_env.to_sym] assert_raise(ActiveRecord::ProtectedEnvironmentError) do ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! end |