Commit b803bc7b authored by Timothy Andrew's avatar Timothy Andrew

Implement review comments from @DouweM.

parent cef10ef7
......@@ -2,8 +2,8 @@ module ProtectedBranchAccess
extend ActiveSupport::Concern
included do
scope :master, -> () { where(access_level: Gitlab::Access::MASTER) }
scope :developer, -> () { where(access_level: Gitlab::Access::DEVELOPER) }
scope :master, -> { where(access_level: Gitlab::Access::MASTER) }
scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
end
def humanize
......
......@@ -11,17 +11,22 @@ module ProtectedBranches
end
def execute
if @developers_can_push
@params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }])
else
@params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }])
end
push_access_level =
if @developers_can_push
Gitlab::Access::DEVELOPER
else
Gitlab::Access::MASTER
end
if @developers_can_merge
@params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }])
else
@params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }])
end
merge_access_level =
if @developers_can_merge
Gitlab::Access::DEVELOPER
else
Gitlab::Access::MASTER
end
@params.merge!(push_access_levels_attributes: [{ access_level: push_access_level }],
merge_access_levels_attributes: [{ access_level: merge_access_level }])
service = ProtectedBranches::CreateService.new(@project, @current_user, @params)
service.execute
......
......@@ -57,11 +57,11 @@ module API
developers_can_merge = to_boolean(params[:developers_can_merge])
developers_can_push = to_boolean(params[:developers_can_push])
params = {
protected_branch_params = {
name: @branch.name,
}
service_args = [user_project, current_user, params,
service_args = [user_project, current_user, protected_branch_params,
developers_can_push: developers_can_push,
developers_can_merge: developers_can_merge]
......
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