From 2c3c5b35549185080296670cfe6710aa80f99944 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Sat, 20 Jan 2018 12:21:49 +0100 Subject: Don't include projects shared as group-descendants When a project is shared with a group, it should not be included as a descendant on the group dashboard. --- app/finders/group_descendants_finder.rb | 6 ++++-- spec/finders/group_descendants_finder_spec.rb | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/finders/group_descendants_finder.rb b/app/finders/group_descendants_finder.rb index 58570a580f1..c77d1fd6019 100644 --- a/app/finders/group_descendants_finder.rb +++ b/app/finders/group_descendants_finder.rb @@ -121,8 +121,10 @@ class GroupDescendantsFinder end def direct_child_projects - GroupProjectsFinder.new(group: parent_group, current_user: current_user, params: params) - .execute + GroupProjectsFinder.new(group: parent_group, + current_user: current_user, + options: { only_owned: true }, + params: params).execute end # Finds all projects nested under `parent_group` or any of its descendant diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb index ae050f36b4a..9cadd9a6000 100644 --- a/spec/finders/group_descendants_finder_spec.rb +++ b/spec/finders/group_descendants_finder_spec.rb @@ -35,6 +35,15 @@ describe GroupDescendantsFinder do expect(finder.execute).to contain_exactly(project) end + it 'does not include projects shared with the group' do + project = create(:project, namespace: group) + other_project = create(:project) + other_project.project_group_links.create(group: group, + group_access: ProjectGroupLink::MASTER) + + expect(finder.execute).to contain_exactly(project) + end + context 'when archived is `true`' do let(:params) { { archived: 'true' } } @@ -64,7 +73,7 @@ describe GroupDescendantsFinder do end context 'with a filter' do - let(:params) { { filter: 'test' } } + let(:params) { { filter: 'tes' } } it 'includes only projects matching the filter' do _other_project = create(:project, namespace: group) -- cgit v1.2.1