Commit e8942846 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Hide ancestor groups in the share group dropdown list

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f592cae1
...@@ -9,6 +9,7 @@ module Projects ...@@ -9,6 +9,7 @@ module Projects
@skip_groups = @group_links.pluck(:group_id) @skip_groups = @group_links.pluck(:group_id)
@skip_groups << @project.namespace_id unless @project.personal? @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 @project_members = MembersFinder.new(@project, current_user).execute
......
...@@ -207,7 +207,7 @@ class Group < Namespace ...@@ -207,7 +207,7 @@ class Group < Namespace
end end
def members_with_parents 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 end
def users_with_parents def users_with_parents
......
---
title: Hide ancestor groups in the share group dropdown list
merge_request: 9965
author:
...@@ -8,7 +8,7 @@ feature 'Project group links', feature: true, js: true do ...@@ -8,7 +8,7 @@ feature 'Project group links', feature: true, js: true do
let!(:group) { create(:group) } let!(:group) { create(:group) }
background do background do
project.team << [master, :master] project.add_master(master)
login_as(master) login_as(master)
end end
...@@ -29,4 +29,26 @@ feature 'Project group links', feature: true, js: true do ...@@ -29,4 +29,26 @@ feature 'Project group links', feature: true, js: true do
end end
end 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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment