Implement review comments from @DouweM.

This commit is contained in:
Timothy Andrew 2016-09-22 20:38:05 +05:30
parent cef10ef7d7
commit b803bc7bb8
3 changed files with 19 additions and 14 deletions

View file

@ -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

View file

@ -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

View file

@ -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]