2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-04-02 01:04:10 -04:00
|
|
|
module ConnectionHelper
|
|
|
|
def run_without_connection
|
|
|
|
original_connection = ActiveRecord::Base.remove_connection
|
2020-01-17 17:08:14 -05:00
|
|
|
yield original_connection.configuration_hash
|
2014-04-02 01:04:10 -04:00
|
|
|
ensure
|
|
|
|
ActiveRecord::Base.establish_connection(original_connection)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Used to drop all cache query plans in tests.
|
|
|
|
def reset_connection
|
|
|
|
original_connection = ActiveRecord::Base.remove_connection
|
|
|
|
ActiveRecord::Base.establish_connection(original_connection)
|
|
|
|
end
|
|
|
|
end
|