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