Commit cce4e322 authored by Thong Kuah's avatar Thong Kuah

Fix fake connection leaking for Ci::ApplicationRecord

After the example has run, the
Ci::ApplicationRecord#connection_specification_name remained stuck as
"Ci::ApplicationRecord" instead of reverting back to
"ActiveRecord::Base".

We call model.remove_connection to fix this.

Also, there is no need to setup a (fake) ci connection, if we already
have one
parent f02c40eb
......@@ -490,11 +490,20 @@ RSpec.describe Gitlab::Database::LoadBalancing::LoadBalancer, :request_store do
describe 'primary connection re-use', :reestablished_active_record_base do
let(:model) { Ci::ApplicationRecord }
before do
# fake additional Database
model.establish_connection(
ActiveRecord::DatabaseConfigurations::HashConfig.new(Rails.env, 'ci', ActiveRecord::Base.connection_db_config.configuration_hash)
)
around do |example|
if Gitlab::Database.has_config?(:ci)
example.run
else
# fake additional Database
model.establish_connection(
ActiveRecord::DatabaseConfigurations::HashConfig.new(Rails.env, 'ci', ActiveRecord::Base.connection_db_config.configuration_hash)
)
example.run
# Cleanup connection_specification_name for Ci::ApplicationRecord
model.remove_connection
end
end
describe '#read' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment