diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-13 06:06:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-13 06:06:31 +0300 |
commit | d41c040fa25a8b4092843b84bf7d839591b6ee09 (patch) | |
tree | 5f7e94d2b6ac79483788eb867b3827af10f5bd82 /spec/graphql/resolvers | |
parent | 4689bac80c8ab86e2b37abf217cc9b3404c5255f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/graphql/resolvers')
-rw-r--r-- | spec/graphql/resolvers/issues_resolver_spec.rb | 29 |
1 files changed, 27 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 |