diff options
Diffstat (limited to 'spec/finders/issues_finder_spec.rb')
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 672318c292e..fb7d4e808fe 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -185,9 +185,9 @@ RSpec.describe IssuesFinder do let(:params) { { milestone_title: group_milestone.title } } before do - project2.update(namespace: group) - issue2.update(milestone: group_milestone) - issue3.update(milestone: group_milestone) + project2.update!(namespace: group) + issue2.update!(milestone: group_milestone) + issue3.update!(milestone: group_milestone) end it 'returns issues assigned to that group milestone' do @@ -668,6 +668,58 @@ RSpec.describe IssuesFinder do end end + context 'filtering by issue type' do + let_it_be(:incident_issue) { create(:incident, project: project1) } + + context 'no type given' do + let(:params) { { issue_types: [] } } + + it 'returns all issues' do + expect(issues).to contain_exactly(incident_issue, issue1, issue2, issue3, issue4) + end + end + + context 'incident type' do + let(:params) { { issue_types: ['incident'] } } + + it 'returns incident issues' do + expect(issues).to contain_exactly(incident_issue) + end + end + + context 'issue type' do + let(:params) { { issue_types: ['issue'] } } + + it 'returns all issues with type issue' do + expect(issues).to contain_exactly(issue1, issue2, issue3, issue4) + end + end + + context 'multiple params' do + let(:params) { { issue_types: %w(issue incident) } } + + it 'returns all issues' do + expect(issues).to contain_exactly(incident_issue, issue1, issue2, issue3, issue4) + end + end + + context 'without array' do + let(:params) { { issue_types: 'incident' } } + + it 'returns incident issues' do + expect(issues).to contain_exactly(incident_issue) + end + end + + context 'invalid params' do + let(:params) { { issue_types: ['nonsense'] } } + + it 'returns no issues' do + expect(issues).to eq(Issue.none) + end + end + end + context 'when the user is unauthorized' do let(:search_user) { nil } |