diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/lib/gitlab/usage_data_queries_spec.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/lib/gitlab/usage_data_queries_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage_data_queries_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage_data_queries_spec.rb b/spec/lib/gitlab/usage_data_queries_spec.rb index 12eac643383..718ab3b2d95 100644 --- a/spec/lib/gitlab/usage_data_queries_spec.rb +++ b/spec/lib/gitlab/usage_data_queries_spec.rb @@ -11,12 +11,24 @@ RSpec.describe Gitlab::UsageDataQueries do it 'returns the raw SQL' do expect(described_class.count(User)).to start_with('SELECT COUNT("users"."id") FROM "users"') end + + it 'does not mix a nil column with keyword arguments' do + expect(described_class).to receive(:raw_sql).with(User, nil) + + described_class.count(User, start: 1, finish: 2) + end end describe '.distinct_count' do it 'returns the raw SQL' do expect(described_class.distinct_count(Issue, :author_id)).to eq('SELECT COUNT(DISTINCT "issues"."author_id") FROM "issues"') end + + it 'does not mix a nil column with keyword arguments' do + expect(described_class).to receive(:raw_sql).with(Issue, nil, :distinct) + + described_class.distinct_count(Issue, nil, start: 1, finish: 2) + end end describe '.redis_usage_data' do @@ -46,4 +58,24 @@ RSpec.describe Gitlab::UsageDataQueries do .to eq('SELECT (SELECT COUNT("users"."id") FROM "users") + (SELECT COUNT("issues"."id") FROM "issues")') end end + + describe 'min/max methods' do + it 'returns nil' do + # user min/max + expect(described_class.minimum_id(User)).to eq(nil) + expect(described_class.maximum_id(User)).to eq(nil) + + # issue min/max + expect(described_class.minimum_id(Issue)).to eq(nil) + expect(described_class.maximum_id(Issue)).to eq(nil) + + # deployment min/max + expect(described_class.minimum_id(Deployment)).to eq(nil) + expect(described_class.maximum_id(Deployment)).to eq(nil) + + # project min/max + expect(described_class.minimum_id(Project)).to eq(nil) + expect(described_class.maximum_id(Project)).to eq(nil) + end + end end |