diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-11-29 14:21:50 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-11-29 15:08:45 +0300 |
commit | 41bf093662a24cc6b68eba3503b56ac44b7f6e69 (patch) | |
tree | 0b116fce9bfd41c548cc498d3d0d6939a20afa07 /app/models/concerns/protected_branch_access.rb | |
parent | 3fc6eff5fce225610812cf3efdfcf8498a7b4144 (diff) |
CE-specific changes gitlab-org/gitlab-ee#1137
- Extract all common {push,merge} access level model code into the
`ProtectedBranchAccess` module
- Use the HTTP verb to define controller specs
Diffstat (limited to 'app/models/concerns/protected_branch_access.rb')
-rw-r--r-- | app/models/concerns/protected_branch_access.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/concerns/protected_branch_access.rb b/app/models/concerns/protected_branch_access.rb index 7fd0905ee81..9dd4d9c6f24 100644 --- a/app/models/concerns/protected_branch_access.rb +++ b/app/models/concerns/protected_branch_access.rb @@ -2,6 +2,9 @@ module ProtectedBranchAccess extend ActiveSupport::Concern included do + belongs_to :protected_branch + delegate :project, to: :protected_branch + scope :master, -> { where(access_level: Gitlab::Access::MASTER) } scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) } end @@ -9,4 +12,10 @@ module ProtectedBranchAccess def humanize self.class.human_access_levels[self.access_level] end + + def check_access(user) + return true if user.is_admin? + + project.team.max_member_access(user.id) >= access_level + end end |