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/protected_branch | |
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/protected_branch')
-rw-r--r-- | app/models/protected_branch/merge_access_level.rb | 9 | ||||
-rw-r--r-- | app/models/protected_branch/push_access_level.rb | 6 |
2 files changed, 1 insertions, 14 deletions
diff --git a/app/models/protected_branch/merge_access_level.rb b/app/models/protected_branch/merge_access_level.rb index 806b3ccd275..771e3376613 100644 --- a/app/models/protected_branch/merge_access_level.rb +++ b/app/models/protected_branch/merge_access_level.rb @@ -1,9 +1,6 @@ class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base include ProtectedBranchAccess - belongs_to :protected_branch - delegate :project, to: :protected_branch - validates :access_level, presence: true, inclusion: { in: [Gitlab::Access::MASTER, Gitlab::Access::DEVELOPER] } @@ -13,10 +10,4 @@ class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base Gitlab::Access::DEVELOPER => "Developers + Masters" }.with_indifferent_access end - - def check_access(user) - return true if user.is_admin? - - project.team.max_member_access(user.id) >= access_level - end end diff --git a/app/models/protected_branch/push_access_level.rb b/app/models/protected_branch/push_access_level.rb index 92e9c51d883..14610cb42b7 100644 --- a/app/models/protected_branch/push_access_level.rb +++ b/app/models/protected_branch/push_access_level.rb @@ -1,9 +1,6 @@ class ProtectedBranch::PushAccessLevel < ActiveRecord::Base include ProtectedBranchAccess - belongs_to :protected_branch - delegate :project, to: :protected_branch - validates :access_level, presence: true, inclusion: { in: [Gitlab::Access::MASTER, Gitlab::Access::DEVELOPER, Gitlab::Access::NO_ACCESS] } @@ -18,8 +15,7 @@ class ProtectedBranch::PushAccessLevel < ActiveRecord::Base def check_access(user) return false if access_level == Gitlab::Access::NO_ACCESS - return true if user.is_admin? - project.team.max_member_access(user.id) >= access_level + super end end |