diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-19 12:13:27 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-19 12:13:27 +0000 |
commit | 9fe6c2b2c2dd92831c93297021b41d6721e4b201 (patch) | |
tree | 004c64b2d777770e606a10500e1a5735c162331a /spec/finders | |
parent | ff97afdd589b0c3dd93db9eca83b13a09a704a2e (diff) | |
parent | ef633d24786707672377312eea850ce2eb63f573 (diff) | |
download | gitlab-ce-9fe6c2b2c2dd92831c93297021b41d6721e4b201.tar.gz |
Merge branch 'add-since-and-until-params-to-issuables' into 'master'
add created_after and created_before params to issuables
Closes #32901
See merge request !12151
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 22 | ||||
-rw-r--r-- | spec/finders/merge_requests_finder_spec.rb | 42 |
2 files changed, 62 insertions, 2 deletions
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 8f2d60f2f1b..8ace1fb5751 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -7,9 +7,9 @@ describe IssuesFinder do set(:project2) { create(:empty_project) } set(:milestone) { create(:milestone, project: project1) } set(:label) { create(:label, project: project2) } - set(:issue1) { create(:issue, author: user, assignees: [user], project: project1, milestone: milestone, title: 'gitlab') } + set(:issue1) { create(:issue, author: user, assignees: [user], project: project1, milestone: milestone, title: 'gitlab', created_at: 1.week.ago) } set(:issue2) { create(:issue, author: user, assignees: [user], project: project2, description: 'gitlab') } - set(:issue3) { create(:issue, author: user2, assignees: [user2], project: project2, title: 'tanuki', description: 'tanuki') } + set(:issue3) { create(:issue, author: user2, assignees: [user2], project: project2, title: 'tanuki', description: 'tanuki', created_at: 1.week.from_now) } describe '#execute' do set(:closed_issue) { create(:issue, author: user2, assignees: [user2], project: project2, state: 'closed') } @@ -215,6 +215,24 @@ describe IssuesFinder do end end + context 'filtering by created_at' do + context 'through created_after' do + let(:params) { { created_after: issue3.created_at } } + + it 'returns issues created on or after the given date' do + expect(issues).to contain_exactly(issue3) + end + end + + context 'through created_before' do + let(:params) { { created_before: issue1.created_at + 1.second } } + + it 'returns issues created on or before the given date' do + expect(issues).to contain_exactly(issue1) + end + end + end + context 'when the user is unauthorized' do let(:search_user) { nil } diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb index 58b7cd5e098..5eb26de6c92 100644 --- a/spec/finders/merge_requests_finder_spec.rb +++ b/spec/finders/merge_requests_finder_spec.rb @@ -46,5 +46,47 @@ describe MergeRequestsFinder do expect(merge_requests).to contain_exactly(merge_request1) end + + context 'with created_after and created_before params' do + let(:project4) { create(:empty_project, forked_from_project: project1) } + + let!(:new_merge_request) do + create(:merge_request, + :simple, + author: user, + created_at: 1.week.from_now, + source_project: project4, + target_project: project1) + end + + let!(:old_merge_request) do + create(:merge_request, + :simple, + author: user, + created_at: 1.week.ago, + source_project: project4, + target_project: project4) + end + + before do + project4.add_master(user) + end + + it 'filters by created_after' do + params = { project_id: project1.id, created_after: new_merge_request.created_at } + + merge_requests = described_class.new(user, params).execute + + expect(merge_requests).to contain_exactly(new_merge_request) + end + + it 'filters by created_before' do + params = { project_id: project4.id, created_before: old_merge_request.created_at + 1.second } + + merge_requests = described_class.new(user, params).execute + + expect(merge_requests).to contain_exactly(old_merge_request) + end + end end end |