diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 18:06:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-17 18:06:17 +0300 |
commit | 238d22c07218adf2b8f3db630ee8b74ca6f29df5 (patch) | |
tree | 23fd5f85efef0fb95eb73bf6395d5b7e8c0f1b9f /spec/finders/todos_finder_spec.rb | |
parent | 6b75320f525f841454f1ab162d141d3610f2e77b (diff) |
Add latest changes from gitlab-org/gitlab@masterlist
Diffstat (limited to 'spec/finders/todos_finder_spec.rb')
-rw-r--r-- | spec/finders/todos_finder_spec.rb | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/spec/finders/todos_finder_spec.rb b/spec/finders/todos_finder_spec.rb index 5d284f4cf17..044e135fa0b 100644 --- a/spec/finders/todos_finder_spec.rb +++ b/spec/finders/todos_finder_spec.rb @@ -16,6 +16,10 @@ describe TodosFinder do end describe '#execute' do + it 'returns no todos if user is nil' do + expect(described_class.new(nil, {}).execute).to be_empty + end + context 'filtering' do let!(:todo1) { create(:todo, user: user, project: project, target: issue) } let!(:todo2) { create(:todo, user: user, group: group, target: merge_request) } @@ -97,14 +101,39 @@ describe TodosFinder do end end - context 'with subgroups' do - let(:subgroup) { create(:group, parent: group) } - let!(:todo3) { create(:todo, user: user, group: subgroup, target: issue) } + context 'by groups' do + context 'with subgroups' 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 + + context 'filtering for multiple groups' do + let_it_be(:group2) { create(:group) } + let_it_be(:group3) { create(:group) } + + let!(:todo1) { create(:todo, user: user, project: project, target: issue) } + let!(:todo2) { create(:todo, user: user, group: group, target: merge_request) } + let!(:todo3) { create(:todo, user: user, group: group2, target: merge_request) } + + let(:subgroup1) { create(:group, parent: group) } + let!(:todo4) { create(:todo, user: user, group: subgroup1, target: issue) } - it 'returns todos from subgroups when filtered by a group' do - todos = finder.new(user, { group_id: group.id }).execute + let(:subgroup2) { create(:group, parent: group2) } + let!(:todo5) { create(:todo, user: user, group: subgroup2, target: issue) } - expect(todos).to match_array([todo1, todo2, todo3]) + let!(:todo6) { create(:todo, user: user, group: group3, target: issue) } + + it 'returns the expected groups' do + todos = finder.new(user, { group_id: [group.id, group2.id] }).execute + + expect(todos).to match_array([todo1, todo2, todo3, todo4, todo5]) + end end end end |