diff options
author | Gosia Ksionek <mksionek@gitlab.com> | 2019-04-04 17:19:57 +0300 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-04-04 17:19:57 +0300 |
commit | 17bee986bc971cc7d04c4b767cc026577eb56c6a (patch) | |
tree | 87f71cd3b3af84ad02e196d3a619f13b634827da /app | |
parent | 702f18261a2ac0b45e2b002055950816ad34e92c (diff) |
Add cr remarks
Chnage method used in model to make it
more efficient database-wise
Add additional spec
Diffstat (limited to 'app')
-rw-r--r-- | app/models/group.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index c77586c4cdc..ac66815705c 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -228,22 +228,21 @@ class Group < Namespace def has_owner?(user) return false unless user - members_with_parents.owners.where(user_id: user).any? + members_with_parents.owners.exists?(user_id: user) end def has_maintainer?(user) return false unless user - members_with_parents.maintainers.where(user_id: user).any? + members_with_parents.maintainers.exists?(user_id: user) end # @deprecated alias_method :has_master?, :has_maintainer? # Check if user is a last owner of the group. - # Parent owners are ignored for nested groups. def last_owner?(user) - owners.include?(user) && owners.size == 1 + has_owner?(user) && members_with_parents.owners.size == 1 end def ldap_synced? |