diff options
Diffstat (limited to 'spec/graphql')
-rw-r--r-- | spec/graphql/resolvers/issues_resolver_spec.rb | 29 | ||||
-rw-r--r-- | spec/graphql/types/issue_sort_enum_spec.rb | 13 |
2 files changed, 40 insertions, 2 deletions
diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb index 2232c9b7d7b..3ac698e0e72 100644 --- a/spec/graphql/resolvers/issues_resolver_spec.rb +++ b/spec/graphql/resolvers/issues_resolver_spec.rb @@ -72,8 +72,33 @@ describe Resolvers::IssuesResolver do expect(resolve_issues(search: 'foo')).to contain_exactly(issue2) end - it 'sort issues' do - expect(resolve_issues(sort: 'created_desc')).to eq [issue2, issue1] + describe 'sorting' do + context 'when sorting by created' do + it 'sorts issues ascending' do + expect(resolve_issues(sort: 'created_asc')).to eq [issue1, issue2] + end + + it 'sorts issues descending' do + expect(resolve_issues(sort: 'created_desc')).to eq [issue2, issue1] + end + end + + context 'when sorting by due date' do + let(:project) { create(:project) } + + let!(:due_issue1) { create(:issue, project: project, due_date: 3.days.from_now) } + let!(:due_issue2) { create(:issue, project: project, due_date: nil) } + let!(:due_issue3) { create(:issue, project: project, due_date: 2.days.ago) } + let!(: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] + end + + it 'sorts issues descending' do + expect(resolve_issues(sort: :due_date_desc)).to eq [due_issue1, due_issue3, due_issue4, due_issue2] + end + end end it 'returns issues user can see' do diff --git a/spec/graphql/types/issue_sort_enum_spec.rb b/spec/graphql/types/issue_sort_enum_spec.rb new file mode 100644 index 00000000000..da7126f3d84 --- /dev/null +++ b/spec/graphql/types/issue_sort_enum_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe GitlabSchema.types['IssueSort'] do + it { expect(described_class.graphql_name).to eq('IssueSort') } + + it_behaves_like 'common sort values' + + it 'exposes all the existing issue sort values' do + expect(described_class.values.keys).to include(*%w[DUE_DATE_ASC DUE_DATE_DESC]) + end +end |