diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-16 12:00:56 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-16 12:08:10 +0530 |
commit | 4ddbbcd11a6f03ae36efd4b9016974c34a1465ed (patch) | |
tree | 5d4386bbcf91a490f3402f7a1a74a4e0084cc50a /lib/gitlab | |
parent | e9f483355ef07a63d664126c1200762bd1e11271 (diff) | |
download | gitlab-ce-4ddbbcd11a6f03ae36efd4b9016974c34a1465ed.tar.gz |
Improve EE compatibility with protected branch access levels.
1. Change a few incorrect `access_level` to `access_levels.first` that
were missed in e805a64.
2. `API::Entities` can iterate over all access levels instead of just
the first one. This makes no difference to CE, and makes it more compatible
with EE.
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/user_access.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb index c55a7fc4d3d..9858d2e7d83 100644 --- a/lib/gitlab/user_access.rb +++ b/lib/gitlab/user_access.rb @@ -32,7 +32,7 @@ module Gitlab if project.protected_branch?(ref) return true if project.empty_repo? && project.user_can_push_to_empty_repo?(user) - access_levels = project.protected_branches.matching(ref).map(&:push_access_level) + access_levels = project.protected_branches.matching(ref).map(&:push_access_levels).flatten access_levels.any? { |access_level| access_level.check_access(user) } else user.can?(:push_code, project) @@ -43,7 +43,7 @@ module Gitlab return false unless user if project.protected_branch?(ref) - access_levels = project.protected_branches.matching(ref).map(&:merge_access_level) + access_levels = project.protected_branches.matching(ref).map(&:merge_access_levels).flatten access_levels.any? { |access_level| access_level.check_access(user) } else user.can?(:push_code, project) |