Commit 8f3b901c authored by James Edwards-Jones's avatar James Edwards-Jones

Fixed developers_can_push in RepoBranch API entity

parent 5442d903
......@@ -14,6 +14,12 @@ module ProtectedRef
end
end
def self.developers_can?(action, ref)
access_levels_for_ref(ref, action: action).any? do |access_level|
access_level.access_level == Gitlab::Access::DEVELOPER
end
end
def self.access_levels_for_ref(ref, action: :push)
self.matching(ref).map(&:"#{action}_access_levels").flatten
end
......
......@@ -214,15 +214,11 @@ module API
end
expose :developers_can_push do |repo_branch, options|
project = options[:project]
access_levels = project.protected_branches.access_levels_for_ref(repo_branch.name, :push)
access_levels.any? { |access_level| access_level.access_level == Gitlab::Access::DEVELOPER }
options[:project].protected_branches.developers_can?(:push, repo_branch.name)
end
expose :developers_can_merge do |repo_branch, options|
project = options[:project]
access_levels = project.protected_branches.access_levels_for_ref(repo_branch.name, :merge)
access_levels.any? { |access_level| access_level.access_level == Gitlab::Access::DEVELOPER }
options[:project].protected_branches.developers_can?(:merge, repo_branch.name)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment