diff options
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 |