diff options
author | Stan Hu <stanhu@gmail.com> | 2018-07-31 12:31:15 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-07-31 12:31:15 -0700 |
commit | 852b5613c5eda43a9dce20ca9a71301f5630b1c6 (patch) | |
tree | 8c9d347a4c7f37a25ce337f134e6c1c0b91c0224 /app/helpers/namespaces_helper.rb | |
parent | 0085b76fb387237af02f717a894c89f7227cb81e (diff) | |
download | gitlab-ce-852b5613c5eda43a9dce20ca9a71301f5630b1c6.tar.gz |
Fix namespaces_helper reporting multiple groups
Diffstat (limited to 'app/helpers/namespaces_helper.rb')
-rw-r--r-- | app/helpers/namespaces_helper.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index 9008db1b300..19aa630007d 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -14,8 +14,11 @@ module NamespacesHelper extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group' end - if extra_group && extra_group.is_a?(Group) && (!Group.exists?(name: extra_group.name) || Ability.allowed?(current_user, :read_group, extra_group)) - groups |= [extra_group] + if extra_group && extra_group.is_a?(Group) + # Avoid duplicate groups if one already exists by that name + existing_group = Group.find_by(name: extra_group.name) + extra_group = existing_group if existing_group + groups |= [extra_group] if Ability.allowed?(current_user, :read_group, extra_group) end options = [] |