DEV: Better clean up for PostgreSQL failover test.

This commit is contained in:
Guo Xiang Tan
2018-07-10 09:53:25 +08:00
parent 5374a0e720
commit 4163f9e61e
2 changed files with 6 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ describe ActiveRecord::ConnectionHandling do
let(:postgresql_fallback_handler) { PostgreSQLFallbackHandler.instance }
before do
@threads = Thread.list
postgresql_fallback_handler.initialized = true
['default', multisite_db].each do |db|
@@ -35,10 +36,13 @@ describe ActiveRecord::ConnectionHandling do
end
after do
Sidekiq.unpause!
postgresql_fallback_handler.setup!
Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
ActiveRecord::Base.unstub(:postgresql_connection)
ActiveRecord::Base.establish_connection
(Thread.list - @threads).each(&:join)
end
describe "#postgresql_fallback_connection" do