summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb
index 8d758ed1655..ead8b174d46 100644
--- a/spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/sql/set_operator_shared_examples.rb
@@ -22,7 +22,7 @@ RSpec.shared_examples 'SQL set operator' do |operator_keyword|
end
it 'skips Model.none segments' do
- empty_relation = User.none
+ empty_relation = User.none.select(:id)
set_operator = described_class.new([empty_relation, relation_1, relation_2])
expect {User.where("users.id IN (#{set_operator.to_sql})").to_a}.not_to raise_error
@@ -44,6 +44,17 @@ RSpec.shared_examples 'SQL set operator' do |operator_keyword|
end
end
+ context 'when uneven select values are used' do
+ let(:relation_1) { User.where(email: 'alice@example.com').select(*User.column_names) }
+ let(:relation_2) { User.where(email: 'bob@example.com') }
+
+ it 'raises error' do
+ expect do
+ described_class.new([relation_1, relation_2])
+ end.to raise_error /Relations with uneven select values were passed/
+ end
+ end
+
describe 'remove_order parameter' do
let(:scopes) do
[