Welcome to mirror list, hosted at ThFree Co, Russian Federation.

union_spec.rb « sql « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9e1cd4419e0b00bdc904f3279db285706a4ae07c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'spec_helper'

describe Gitlab::SQL::Union do
  describe '#to_sql' do
    it 'returns a String joining relations together using a UNION' do
      rel1  = User.where(email: 'alice@example.com')
      rel2  = User.where(email: 'bob@example.com')
      union = described_class.new([rel1, rel2])

      sql1 = rel1.reorder(nil).to_sql
      sql2 = rel2.reorder(nil).to_sql

      expect(union.to_sql).to eq("#{sql1}\nUNION\n#{sql2}")
    end
  end
end