diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/lib/gitlab/issuables_count_for_state_spec.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/lib/gitlab/issuables_count_for_state_spec.rb')
-rw-r--r-- | spec/lib/gitlab/issuables_count_for_state_spec.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/lib/gitlab/issuables_count_for_state_spec.rb b/spec/lib/gitlab/issuables_count_for_state_spec.rb index d96152e47ea..a6170c146ab 100644 --- a/spec/lib/gitlab/issuables_count_for_state_spec.rb +++ b/spec/lib/gitlab/issuables_count_for_state_spec.rb @@ -4,14 +4,15 @@ require 'spec_helper' RSpec.describe Gitlab::IssuablesCountForState do let(:finder) do - double(:finder, count_by_state: { opened: 2, closed: 1 }) + double(:finder, current_user: nil, params: {}, count_by_state: { opened: 2, closed: 1 }) end - let(:counter) { described_class.new(finder) } + let(:project) { nil } + let(:fast_fail) { nil } + let(:counter) { described_class.new(finder, project, fast_fail: fast_fail) } describe 'project given' do let(:project) { build(:project) } - let(:counter) { described_class.new(finder, project) } it 'provides the project' do expect(counter.project).to eq(project) @@ -50,5 +51,19 @@ RSpec.describe Gitlab::IssuablesCountForState do it 'returns 0 when using an invalid state name as a String' do expect(counter['kittens']).to be_zero end + + context 'fast_fail enabled' do + let(:fast_fail) { true } + + it 'returns the expected value' do + expect(counter[:closed]).to eq(1) + end + + it 'returns -1 when the database times out' do + expect(finder).to receive(:count_by_state).and_raise(ActiveRecord::QueryCanceled) + + expect(counter[:closed]).to eq(-1) + end + end end end |