diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 12:09:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-16 12:09:29 +0300 |
commit | 3fd97b4bba24ca412112aad025a38a32c7a6cf8c (patch) | |
tree | 4aacc8a184522bcbc3db68df47620bc3d2cfcfd9 /spec/models/zoom_meeting_spec.rb | |
parent | c52239391bf29f640e1e0af98edbd337c0293940 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/zoom_meeting_spec.rb')
-rw-r--r-- | spec/models/zoom_meeting_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/models/zoom_meeting_spec.rb b/spec/models/zoom_meeting_spec.rb index 3dad957a1ce..d496b968f1e 100644 --- a/spec/models/zoom_meeting_spec.rb +++ b/spec/models/zoom_meeting_spec.rb @@ -151,4 +151,51 @@ describe ZoomMeeting do it_behaves_like 'can remove meetings' end end + + describe '.distinct_count_by' do + let(:issue_1) { create(:issue) } + let(:issue_2) { create(:issue) } + + context 'two meetings for the same issue' do + before do + create(:zoom_meeting, issue: issue_1) + create(:zoom_meeting, :removed_from_issue, issue: issue_1) + end + + it 'returns a count of 1' do + expect(described_class.distinct_count_by(:issue_id)).to eq(1) + end + + context 'when given no colum to count' do + it 'counts by :id and returns a count of 2' do + expect(described_class.distinct_count_by).to eq(2) + end + end + end + + context 'one meeting for each issue' do + it 'returns a count of 2' do + create(:zoom_meeting, issue: issue_1) + create(:zoom_meeting, issue: issue_2) + + expect(described_class.distinct_count_by(:issue_id)).to eq(2) + end + end + + context 'the count query times out' do + before do + allow_next_instance_of(ActiveRecord::Relation) do |instance| + allow(instance).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new('')) + end + end + + it 'does not raise an error' do + expect { described_class.distinct_count_by(:issue_id) }.not_to raise_error + end + + it 'returns -1' do + expect(described_class.distinct_count_by(:issue_id)).to eq(-1) + end + end + end end |