mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix fixture tests that replace connection handler
These tests have been failing intermittently since
054e19d086
was merged.
They replace the connection handler during setup, but before that can
happen the existing handler's pool configuration has already been saved
by `setup_shared_connection_pool`. Later when the test calls
`teardown_shared_connection_pool`, it tries to restore connection pools
that do not exist in the new handler and blows up.
We can avoid this problem by calling `teardown_shared_connection_pool`
to clear the saved pools before replacing the connection handler.
This commit is contained in:
parent
3c5cbe8401
commit
79744bc335
1 changed files with 6 additions and 2 deletions
|
@ -1433,9 +1433,11 @@ if current_adapter?(:SQLite3Adapter) && !in_memory_db?
|
|||
@prev_configs, ActiveRecord::Base.configurations = ActiveRecord::Base.configurations, config
|
||||
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(ENV["RAILS_ENV"], "readonly", readonly_config)
|
||||
|
||||
teardown_shared_connection_pool
|
||||
|
||||
handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
|
||||
handler.establish_connection(db_config)
|
||||
ActiveRecord::Base.connection_handler = handler
|
||||
handler.establish_connection(db_config)
|
||||
|
||||
ActiveRecord::Base.connects_to(database: { writing: :default, reading: :readonly })
|
||||
|
||||
|
@ -1546,12 +1548,14 @@ if current_adapter?(:SQLite3Adapter) && !in_memory_db?
|
|||
@prev_configs, ActiveRecord::Base.configurations = ActiveRecord::Base.configurations, config
|
||||
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(ENV["RAILS_ENV"], "readonly", readonly_config)
|
||||
|
||||
teardown_shared_connection_pool
|
||||
|
||||
handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
|
||||
ActiveRecord::Base.connection_handler = handler
|
||||
handler.establish_connection(db_config)
|
||||
assert_deprecated do
|
||||
ActiveRecord::Base.connection_handlers = {}
|
||||
end
|
||||
ActiveRecord::Base.connection_handler = handler
|
||||
ActiveRecord::Base.connects_to(database: { writing: :default, reading: :readonly })
|
||||
|
||||
setup_shared_connection_pool
|
||||
|
|
Loading…
Reference in a new issue