diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-04-04 04:05:42 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-04-04 04:05:42 +0300 |
commit | 1e15444ae6dda02744db42d08c817252953c7b1f (patch) | |
tree | fbc15aed4220716b8844546601320c32624a4e7e /lib/gitlab/user_access.rb | |
parent | 90c8bb8301b4bc3268a5fa4ea8bddafbc29d6871 (diff) |
Cleanup & tests for UserAccess#can_create_tag?
Diffstat (limited to 'lib/gitlab/user_access.rb')
-rw-r--r-- | lib/gitlab/user_access.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb index 5541a45e948..6af5de4dc08 100644 --- a/lib/gitlab/user_access.rb +++ b/lib/gitlab/user_access.rb @@ -28,14 +28,11 @@ module Gitlab true end - #TODO: Test this - #TODO move most to ProtectedTag::AccessChecker. Or maybe UserAccess::Protections::Tag - #TODO: then consider removing method, if it turns out can_access_git? and can?(:push_code are checked in change_access - def can_push_tag?(ref) + def can_create_tag?(ref) return false unless can_access_git? if ProtectedTag.protected?(project, ref) - project.protected_tags.matching_refs_accesible_to(ref, user) + project.protected_tags.protected_ref_accessible_to?(ref, user) else user.can?(:push_code, project) end @@ -47,7 +44,7 @@ module Gitlab if ProtectedBranch.protected?(project, ref) return true if project.empty_repo? && project.user_can_push_to_empty_repo?(user) - has_access = project.protected_branches.matching_refs_accesible_to(ref, user, action: :push) + has_access = project.protected_branches.protected_ref_accessible_to?(ref, user, action: :push) has_access || !project.repository.branch_exists?(ref) && can_merge_to_branch?(ref) else @@ -59,7 +56,7 @@ module Gitlab return false unless can_access_git? if ProtectedBranch.protected?(project, ref) - project.protected_branches.matching_refs_accesible_to(ref, user, action: :merge) + project.protected_branches.protected_ref_accessible_to?(ref, user, action: :merge) else user.can?(:push_code, project) end |