Commit 5ae87f35 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'add_assertion_for_disable_prepared_statements' into 'master'

Properly assert that AR has disabled prepared statements

See merge request gitlab-org/gitlab!61092
parents 06d7976c 597b6874
......@@ -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