diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-03-21 13:49:20 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-03-21 13:49:20 +0000 |
commit | 0ebf14621fe02adbf874bcb694a7be78794ec89c (patch) | |
tree | 0f3cbb0d45cb051eecd5bd902451dfd6dd4c1f68 | |
parent | 8548aaa08d226478bdb07bea9c36d821694dcae8 (diff) | |
parent | e8942846c656d95d58d283db88c481a6a97face4 (diff) | |
download | gitlab-ce-0ebf14621fe02adbf874bcb694a7be78794ec89c.tar.gz |
Merge branch 'dz-hide-share-group-ancestors' into 'master'
Hide ancestor groups in the share group dropdown list
Closes #29311
See merge request !9965
-rw-r--r-- | app/controllers/projects/settings/members_controller.rb | 1 | ||||
-rw-r--r-- | app/models/group.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/dz-hide-share-group-ancestors.yml | 4 | ||||
-rw-r--r-- | spec/features/projects/group_links_spec.rb | 24 |
4 files changed, 29 insertions, 2 deletions
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 |