summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/bulk_update_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/bulk_update_spec.rb')
-rw-r--r--spec/lib/gitlab/database/bulk_update_spec.rb53
1 files changed, 23 insertions, 30 deletions
diff --git a/spec/lib/gitlab/database/bulk_update_spec.rb b/spec/lib/gitlab/database/bulk_update_spec.rb
index dbafada26ca..9a6463c99fa 100644
--- a/spec/lib/gitlab/database/bulk_update_spec.rb
+++ b/spec/lib/gitlab/database/bulk_update_spec.rb
@@ -91,45 +91,38 @@ RSpec.describe Gitlab::Database::BulkUpdate do
.to eq(['MR a', 'Issue a', 'Issue b'])
end
- shared_examples 'basic functionality' do
- it 'sets multiple values' do
- create_default(:user)
- create_default(:project)
-
- i_a, i_b = create_list(:issue, 2)
+ context 'validates prepared_statements support', :reestablished_active_record_base do
+ using RSpec::Parameterized::TableSyntax
- mapping = {
- i_a => { title: 'Issue a' },
- i_b => { title: 'Issue b' }
- }
+ where(:prepared_statements) do
+ [false, true]
+ end
- described_class.execute(%i[title], mapping)
+ before do
+ configuration_hash = ActiveRecord::Base.connection_db_config.configuration_hash
- expect([i_a, i_b].map { |x| x.reset.title })
- .to eq(['Issue a', 'Issue b'])
+ ActiveRecord::Base.establish_connection(
+ configuration_hash.merge(prepared_statements: prepared_statements)
+ )
end
- end
- include_examples 'basic functionality'
+ with_them do
+ it 'sets multiple values' do
+ create_default(:user)
+ create_default(:project)
- context 'when prepared statements are configured differently to the normal test environment' do
- before do
- klass = Class.new(ActiveRecord::Base) do
- def self.abstract_class?
- true # So it gets its own connection
- end
- end
+ i_a, i_b = create_list(:issue, 2)
- stub_const('ActiveRecordBasePreparedStatementsInverted', klass)
+ mapping = {
+ i_a => { title: 'Issue a' },
+ i_b => { title: 'Issue b' }
+ }
- c = ActiveRecord::Base.connection.instance_variable_get(:@config)
- inverted = c.merge(prepared_statements: !ActiveRecord::Base.connection.prepared_statements)
- ActiveRecordBasePreparedStatementsInverted.establish_connection(inverted)
+ described_class.execute(%i[title], mapping)
- allow(ActiveRecord::Base).to receive(:connection_specification_name)
- .and_return(ActiveRecordBasePreparedStatementsInverted.connection_specification_name)
+ expect([i_a, i_b].map { |x| x.reset.title })
+ .to eq(['Issue a', 'Issue b'])
+ end
end
-
- include_examples 'basic functionality'
end
end