diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/graphql/resolvers/issues_resolver_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/graphql/resolvers/issues_resolver_spec.rb')
-rw-r--r-- | spec/graphql/resolvers/issues_resolver_spec.rb | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb index 43cbd4d2bdd..f6f746a8572 100644 --- a/spec/graphql/resolvers/issues_resolver_spec.rb +++ b/spec/graphql/resolvers/issues_resolver_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Resolvers::IssuesResolver do include GraphqlHelpers - let(:current_user) { create(:user) } + let_it_be(:current_user) { create(:user) } let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, group: group) } @@ -25,7 +25,7 @@ RSpec.describe Resolvers::IssuesResolver do end context "with a project" do - before do + before_all do project.add_developer(current_user) create(:label_link, label: label1, target: issue1) create(:label_link, label: label1, target: issue2) @@ -43,11 +43,11 @@ RSpec.describe Resolvers::IssuesResolver do end it 'filters by milestone' do - expect(resolve_issues(milestone_title: milestone.title)).to contain_exactly(issue1) + expect(resolve_issues(milestone_title: [milestone.title])).to contain_exactly(issue1) end it 'filters by assignee_username' do - expect(resolve_issues(assignee_username: assignee.username)).to contain_exactly(issue2) + expect(resolve_issues(assignee_username: [assignee.username])).to contain_exactly(issue2) end it 'filters by two assignees' do @@ -112,15 +112,19 @@ RSpec.describe Resolvers::IssuesResolver do describe 'filters by issue_type' do it 'filters by a single type' do - expect(resolve_issues(issue_types: ['incident'])).to contain_exactly(issue1) + expect(resolve_issues(types: %w[incident])).to contain_exactly(issue1) + end + + it 'filters by a single type, negative assertion' do + expect(resolve_issues(types: %w[issue])).not_to include(issue1) end it 'filters by more than one type' do - expect(resolve_issues(issue_types: %w(incident issue))).to contain_exactly(issue1, issue2) + expect(resolve_issues(types: %w[incident issue])).to contain_exactly(issue1, issue2) end it 'ignores the filter if none given' do - expect(resolve_issues(issue_types: [])).to contain_exactly(issue1, issue2) + expect(resolve_issues(types: [])).to contain_exactly(issue1, issue2) end end @@ -143,44 +147,44 @@ RSpec.describe Resolvers::IssuesResolver do describe 'sorting' do context 'when sorting by created' do it 'sorts issues ascending' do - expect(resolve_issues(sort: 'created_asc')).to eq [issue1, issue2] + expect(resolve_issues(sort: 'created_asc').to_a).to eq [issue1, issue2] end it 'sorts issues descending' do - expect(resolve_issues(sort: 'created_desc')).to eq [issue2, issue1] + expect(resolve_issues(sort: 'created_desc').to_a).to eq [issue2, issue1] end end context 'when sorting by due date' do - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :public) } let_it_be(:due_issue1) { create(:issue, project: project, due_date: 3.days.from_now) } let_it_be(:due_issue2) { create(:issue, project: project, due_date: nil) } let_it_be(:due_issue3) { create(:issue, project: project, due_date: 2.days.ago) } let_it_be(:due_issue4) { create(:issue, project: project, due_date: nil) } it 'sorts issues ascending' do - expect(resolve_issues(sort: :due_date_asc)).to eq [due_issue3, due_issue1, due_issue4, due_issue2] + expect(resolve_issues(sort: :due_date_asc).to_a).to eq [due_issue3, due_issue1, due_issue4, due_issue2] end it 'sorts issues descending' do - expect(resolve_issues(sort: :due_date_desc)).to eq [due_issue1, due_issue3, due_issue4, due_issue2] + expect(resolve_issues(sort: :due_date_desc).to_a).to eq [due_issue1, due_issue3, due_issue4, due_issue2] end end context 'when sorting by relative position' do - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :public) } let_it_be(:relative_issue1) { create(:issue, project: project, relative_position: 2000) } let_it_be(:relative_issue2) { create(:issue, project: project, relative_position: nil) } let_it_be(:relative_issue3) { create(:issue, project: project, relative_position: 1000) } let_it_be(:relative_issue4) { create(:issue, project: project, relative_position: nil) } it 'sorts issues ascending' do - expect(resolve_issues(sort: :relative_position_asc)).to eq [relative_issue3, relative_issue1, relative_issue4, relative_issue2] + expect(resolve_issues(sort: :relative_position_asc).to_a).to eq [relative_issue3, relative_issue1, relative_issue4, relative_issue2] end end context 'when sorting by priority' do - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :public) } let_it_be(:early_milestone) { create(:milestone, project: project, due_date: 10.days.from_now) } let_it_be(:late_milestone) { create(:milestone, project: project, due_date: 30.days.from_now) } let_it_be(:priority_label1) { create(:label, project: project, priority: 1) } @@ -200,7 +204,7 @@ RSpec.describe Resolvers::IssuesResolver do end context 'when sorting by label priority' do - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :public) } let_it_be(:label1) { create(:label, project: project, priority: 1) } let_it_be(:label2) { create(:label, project: project, priority: 5) } let_it_be(:label3) { create(:label, project: project, priority: 10) } @@ -219,7 +223,7 @@ RSpec.describe Resolvers::IssuesResolver do end context 'when sorting by milestone due date' do - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :public) } let_it_be(:early_milestone) { create(:milestone, project: project, due_date: 10.days.from_now) } let_it_be(:late_milestone) { create(:milestone, project: project, due_date: 30.days.from_now) } let_it_be(:milestone_issue1) { create(:issue, project: project) } @@ -236,17 +240,17 @@ RSpec.describe Resolvers::IssuesResolver do end context 'when sorting by severity' do - let_it_be(:project) { create(:project) } + let_it_be(:project) { create(:project, :public) } let_it_be(:issue_high_severity) { create_issue_with_severity(project, severity: :high) } let_it_be(:issue_low_severity) { create_issue_with_severity(project, severity: :low) } let_it_be(:issue_no_severity) { create(:incident, project: project) } it 'sorts issues ascending' do - expect(resolve_issues(sort: :severity_asc)).to eq([issue_no_severity, issue_low_severity, issue_high_severity]) + expect(resolve_issues(sort: :severity_asc).to_a).to eq([issue_no_severity, issue_low_severity, issue_high_severity]) end it 'sorts issues descending' do - expect(resolve_issues(sort: :severity_desc)).to eq([issue_high_severity, issue_low_severity, issue_no_severity]) + expect(resolve_issues(sort: :severity_desc).to_a).to eq([issue_high_severity, issue_low_severity, issue_no_severity]) end end end @@ -267,7 +271,9 @@ RSpec.describe Resolvers::IssuesResolver do it 'batches queries that only include IIDs', :request_store do result = batch_sync(max_queries: 2) do - resolve_issues(iid: issue1.iid) + resolve_issues(iids: issue2.iid) + [issue1, issue2] + .map { |issue| resolve_issues(iid: issue.iid.to_s) } + .flat_map(&:to_a) end expect(result).to contain_exactly(issue1, issue2) |