BigW Consortium Gitlab

Commit 670a052f by Toon Claes

GroupsFinder should also returns groups of authorized projects

When a user is authorized to a private project, the group of the project should also be returned by the GroupsFinder.
parent 86145951
......@@ -16,7 +16,10 @@ class GroupsFinder < UnionFinder
def all_groups
groups = []
groups << Group.member_self_and_descendants(current_user.id) if current_user
if current_user
groups << Group.member_self_and_descendants(current_user.id)
groups << Group.where(id: current_user.authorized_projects.select(:namespace_id))
end
groups << Group.unscoped.public_to_user(current_user)
groups
......
......@@ -77,6 +77,15 @@ describe GroupsFinder do
is_expected.to contain_exactly(public_subgroup, internal_subgroup, private_subgroup)
end
end
context 'authorized to private project' do
it 'returns the subgroup of the project' do
subproject = create(:empty_project, :private, namespace: private_subgroup)
subproject.add_guest(user)
is_expected.to include(private_subgroup)
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