BigW Consortium Gitlab

Commit b803bc7b by 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,17 +11,22 @@ module ProtectedBranches ...@@ -11,17 +11,22 @@ module ProtectedBranches
end end
def execute def execute
if @developers_can_push push_access_level =
@params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) if @developers_can_push
else Gitlab::Access::DEVELOPER
@params.merge!(push_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) else
end Gitlab::Access::MASTER
end
if @developers_can_merge merge_access_level =
@params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::DEVELOPER }]) if @developers_can_merge
else Gitlab::Access::DEVELOPER
@params.merge!(merge_access_levels_attributes: [{ access_level: Gitlab::Access::MASTER }]) else
end 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 = ProtectedBranches::CreateService.new(@project, @current_user, @params)
service.execute service.execute
......
...@@ -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