1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test
bogdanvlviv 5f244f6b06
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
2018-09-04 23:08:54 +03:00
..
active_record/connection_adapters Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
assets Use YAML to serialize schema cache 2016-11-27 22:09:58 -05:00
cases Fix tests in activerecord/test/cases/tasks/database_tasks_test.rb 2018-09-04 23:08:54 +03:00
fixtures Ensure to calculate column aliases after all table aliases are constructed 2018-06-19 22:21:51 +09:00
migrations Fix occurrences Fixnum|Bignum 2018-03-04 20:44:30 +02:00
models Fix regression setting children record in parent before_save callback. 2018-09-03 13:34:24 +08:00
schema add mysql and sqlite3 default test 2018-09-01 22:09:01 -04:00
support Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
config.example.yml Fix tests for prepared_statements: false and queries hitting #select_all 2016-11-19 21:52:52 +05:30
config.rb Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00