Commit b803bc7b authored by Timothy Andrew's avatar Timothy Andrew

Implement review comments from @DouweM.

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