Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-07-25 12:12:52 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-07-29 12:50:39 +0300
commit7b2ad2d5b99d84fc2d2c11a654085afc02a05bb1 (patch)
tree3ee132c1ad1187e0905f08b6f360a18bd8a1519f /app/models/protected_branch
parentb3a29b3180c4edda33d82fc3564bd4991831e06c (diff)
Implement review comments from @dbalexandre.
1. Remove `master_or_greater?` and `developer_or_greater?` in favor of `max_member_access`, which is a lot nicer. 2. Remove a number of instances of `include Gitlab::Database::MigrationHelpers` in migrations that don't need this module. Also remove comments where not necessary. 3. Remove duplicate entry in CHANGELOG. 4. Move `ProtectedBranchAccessSelect` from Coffeescript to ES6. 5. Split the `set_access_levels!` method in two - one each for `merge` and `push` access levels.
Diffstat (limited to 'app/models/protected_branch')
-rw-r--r--app/models/protected_branch/merge_access_level.rb14
-rw-r--r--app/models/protected_branch/push_access_level.rb17
2 files changed, 19 insertions, 12 deletions
diff --git a/app/models/protected_branch/merge_access_level.rb b/app/models/protected_branch/merge_access_level.rb
index 632e47b028f..17a3a86c3e1 100644
--- a/app/models/protected_branch/merge_access_level.rb
+++ b/app/models/protected_branch/merge_access_level.rb
@@ -12,11 +12,15 @@ class ProtectedBranch::MergeAccessLevel < ActiveRecord::Base
end
def check_access(user)
- if masters?
- user.can?(:push_code, project) if project.team.master_or_greater?(user)
- elsif developers?
- user.can?(:push_code, project) if project.team.developer_or_greater?(user)
- end
+ return true if user.is_admin?
+
+ min_member_access = if masters?
+ Gitlab::Access::MASTER
+ elsif developers?
+ Gitlab::Access::DEVELOPER
+ end
+
+ project.team.max_member_access(user.id) >= min_member_access
end
def humanize
diff --git a/app/models/protected_branch/push_access_level.rb b/app/models/protected_branch/push_access_level.rb
index 35d4ad93231..22096b13300 100644
--- a/app/models/protected_branch/push_access_level.rb
+++ b/app/models/protected_branch/push_access_level.rb
@@ -13,13 +13,16 @@ class ProtectedBranch::PushAccessLevel < ActiveRecord::Base
end
def check_access(user)
- if masters?
- user.can?(:push_code, project) if project.team.master_or_greater?(user)
- elsif developers?
- user.can?(:push_code, project) if project.team.developer_or_greater?(user)
- elsif no_one?
- false
- end
+ return false if no_one?
+ return true if user.is_admin?
+
+ min_member_access = if masters?
+ Gitlab::Access::MASTER
+ elsif developers?
+ Gitlab::Access::DEVELOPER
+ end
+
+ project.team.max_member_access(user.id) >= min_member_access
end
def humanize