summaryrefslogtreecommitdiff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-11-29 16:51:50 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-11-29 17:38:45 +0530
commit41bf093662a24cc6b68eba3503b56ac44b7f6e69 (patch)
tree0b116fce9bfd41c548cc498d3d0d6939a20afa07 /app/models/concerns
parent3fc6eff5fce225610812cf3efdfcf8498a7b4144 (diff)
downloadgitlab-ce-41bf093662a24cc6b68eba3503b56ac44b7f6e69.tar.gz
CE-specific changes gitlab-org/gitlab-ee#1137ee-1137-follow-up-protected-branch-users-and-groups
- 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')
-rw-r--r--app/models/concerns/protected_branch_access.rb9
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