diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-09-03 11:40:16 +0300 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2018-09-04 23:08:54 +0300 |
commit | 5f244f6b0680f161280d3832943e0e9632a9c0de (patch) | |
tree | aad778295e8e86b021ce737c616d31c0dbc2f70a /actionpack/test/fixtures/helpers/just_me_helper.rb | |
parent | fb3642b0caf42b0554a8fd0672943f4da1643b2c (diff) | |
download | rails-5f244f6b0680f161280d3832943e0e9632a9c0de.tar.gz rails-5f244f6b0680f161280d3832943e0e9632a9c0de.tar.bz2 rails-5f244f6b0680f161280d3832943e0e9632a9c0de.zip |
Fix tests in `activerecord/test/cases/tasks/database_tasks_test.rb`
After #33637 some tests in `activerecord/test/cases/tasks/database_tasks_test.rb`
don't assert anything.
We used to stub `ActiveRecord::Base::configurations` method in those
tests like `ActiveRecord::Base.stub(:configurations, @configurations) {}`.
Since #33637 `ActiveRecord::Base::configurations` is a `ActiveRecord::DatabaseConfigurations`
object(not a Hash object) we can't do so anymore.
`ActiveRecord::DatabaseConfigurations` object builds during `ActiveRecord::Base::configurations=`.
We can replace `ActiveRecord::Base.stub(:configurations, @configurations) {}` to
```
begin
old_configurations = ActiveRecord::Base.configurations
ActiveRecord::Base.configurations = @configurations
# ...
ensure
ActiveRecord::Base.configurations = old_configurations
end
```
Also I fixed tests in `activerecord/test/cases/tasks/legacy_database_tasks_test.rb`
But currently It looks like duplication of
`activerecord/test/cases/tasks/database_tasks_test.rb`.
We should improve those tests or remove them.
I've tried (in `activerecord/test/cases/tasks/legacy_database_tasks_test.rb` file):
```
def with_stubbed_configurations
old_configurations = ActiveRecord::Base.configurations.to_h
ActiveRecord::Base.configurations = @configurations
ActiveRecord::Base.stub(:configurations, ActiveRecord::Base.configurations.to_h) do
yield
end
ensure
ActiveRecord::Base.configurations = old_configurations
end
```
but it causes erros in tests cases.
After discussion we decided to remove
`activerecord/test/cases/tasks/legacy_database_tasks_test.rb`
Related to #33637
Diffstat (limited to 'actionpack/test/fixtures/helpers/just_me_helper.rb')
0 files changed, 0 insertions, 0 deletions