Commit 597b6874 authored by Thong Kuah's avatar Thong Kuah

Properly assert that AR has disabled prepared statements

parent d780b8ba
......@@ -61,19 +61,24 @@ RSpec.describe Gitlab::Database do
end
describe '.disable_prepared_statements' do
it 'disables prepared statements' do
config = {}
around do |example|
original_config = ::Gitlab::Database.config
example.run
expect(ActiveRecord::Base.configurations).to receive(:[])
.with(Rails.env)
.and_return(config)
ActiveRecord::Base.establish_connection(original_config)
end
it 'disables prepared statements' do
ActiveRecord::Base.establish_connection(::Gitlab::Database.config.merge(prepared_statements: true))
expect(ActiveRecord::Base.connection.prepared_statements).to eq(true)
expect(ActiveRecord::Base).to receive(:establish_connection)
.with({ 'prepared_statements' => false })
.with(a_hash_including({ 'prepared_statements' => false })).and_call_original
described_class.disable_prepared_statements
expect(config['prepared_statements']).to eq(false)
expect(ActiveRecord::Base.connection.prepared_statements).to eq(false)
end
end
......
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