diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 12:35:32 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 12:35:32 +0000 |
commit | b3deca7a2606a6b2cef464ed08417be4ffb0cb6b (patch) | |
tree | 58cb99a58196581520303a57e9f2024553649eae /spec/finders | |
parent | 411070c3afa621a0bdc741617c1d17f54205b81a (diff) | |
parent | 6dc7490789237a84b66baaaf4c6deea5ec3bf2de (diff) | |
download | gitlab-ce-b3deca7a2606a6b2cef464ed08417be4ffb0cb6b.tar.gz |
Merge branch 'group-todos' into 'master'
Group todos
See merge request gitlab-org/gitlab-ce!20675
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/todos_finder_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/finders/todos_finder_spec.rb b/spec/finders/todos_finder_spec.rb index 9747b9402a7..7f7cfb2cb98 100644 --- a/spec/finders/todos_finder_spec.rb +++ b/spec/finders/todos_finder_spec.rb @@ -5,12 +5,50 @@ describe TodosFinder do let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, namespace: group) } + let(:issue) { create(:issue, project: project) } + let(:merge_request) { create(:merge_request, source_project: project) } let(:finder) { described_class } before do group.add_developer(user) end + describe '#execute' do + context 'filtering' do + let!(:todo1) { create(:todo, user: user, project: project, target: issue) } + let!(:todo2) { create(:todo, user: user, group: group, target: merge_request) } + + it 'returns correct todos when filtered by a project' do + todos = finder.new(user, { project_id: project.id }).execute + + expect(todos).to match_array([todo1]) + end + + it 'returns correct todos when filtered by a group' do + todos = finder.new(user, { group_id: group.id }).execute + + expect(todos).to match_array([todo1, todo2]) + end + + it 'returns correct todos when filtered by a type' do + todos = finder.new(user, { type: 'Issue' }).execute + + expect(todos).to match_array([todo1]) + end + + context 'with subgroups', :nested_groups do + let(:subgroup) { create(:group, parent: group) } + let!(:todo3) { create(:todo, user: user, group: subgroup, target: issue) } + + it 'returns todos from subgroups when filtered by a group' do + todos = finder.new(user, { group_id: group.id }).execute + + expect(todos).to match_array([todo1, todo2, todo3]) + end + end + end + end + describe '#sort' do context 'by date' do let!(:todo1) { create(:todo, user: user, project: project) } |