From 3bc15df7501bc6192f00d17f98926877c6cd60d8 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Mar 2017 13:49:20 +0000 Subject: Merge branch 'dz-hide-share-group-ancestors' into 'master' Hide ancestor groups in the share group dropdown list Closes #29311 See merge request !9965 --- .../projects/settings/members_controller.rb | 1 + app/models/group.rb | 2 +- .../unreleased/dz-hide-share-group-ancestors.yml | 4 ++++ spec/features/projects/group_links_spec.rb | 24 +++++++++++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/dz-hide-share-group-ancestors.yml diff --git a/app/controllers/projects/settings/members_controller.rb b/app/controllers/projects/settings/members_controller.rb index cbfa2afa959..54f9dceddef 100644 --- a/app/controllers/projects/settings/members_controller.rb +++ b/app/controllers/projects/settings/members_controller.rb @@ -9,6 +9,7 @@ module Projects @skip_groups = @group_links.pluck(:group_id) @skip_groups << @project.namespace_id unless @project.personal? + @skip_groups += @project.group.ancestors.pluck(:id) if @project.group @project_members = MembersFinder.new(@project, current_user).execute diff --git a/app/models/group.rb b/app/models/group.rb index bd0ecae3da4..60274386103 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -207,7 +207,7 @@ class Group < Namespace end def members_with_parents - GroupMember.non_request.where(source_id: ancestors.map(&:id).push(id)) + GroupMember.non_request.where(source_id: ancestors.pluck(:id).push(id)) end def users_with_parents diff --git a/changelogs/unreleased/dz-hide-share-group-ancestors.yml b/changelogs/unreleased/dz-hide-share-group-ancestors.yml new file mode 100644 index 00000000000..743c4fd56ca --- /dev/null +++ b/changelogs/unreleased/dz-hide-share-group-ancestors.yml @@ -0,0 +1,4 @@ +--- +title: Hide ancestor groups in the share group dropdown list +merge_request: 9965 +author: diff --git a/spec/features/projects/group_links_spec.rb b/spec/features/projects/group_links_spec.rb index 8b302a6aa23..4c28205da9b 100644 --- a/spec/features/projects/group_links_spec.rb +++ b/spec/features/projects/group_links_spec.rb @@ -8,7 +8,7 @@ feature 'Project group links', feature: true, js: true do let!(:group) { create(:group) } background do - project.team << [master, :master] + project.add_master(master) login_as(master) end @@ -29,4 +29,26 @@ feature 'Project group links', feature: true, js: true do end end end + + context 'nested group project' do + let!(:nested_group) { create(:group, parent: group) } + let!(:another_group) { create(:group) } + let!(:project) { create(:project, namespace: nested_group) } + + background do + group.add_master(master) + another_group.add_master(master) + end + + it 'does not show ancestors' do + visit namespace_project_settings_members_path(project.namespace, project) + + click_link 'Search for a group' + + page.within '.select2-drop' do + expect(page).to have_content(another_group.name) + expect(page).not_to have_content(group.name) + end + end + end end -- cgit v1.2.1