Commit eb57028b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'improve-project-approvals-code-quality' into 'master'

Refactor project approvals param filter

See merge request gitlab-org/gitlab!26339
parents 7985d778 f54baa5f
......@@ -8,18 +8,16 @@ module API
ARRAY_COERCION_LAMBDA = ->(val) { val.empty? ? [] : Array.wrap(val) }
helpers do
def filter_params(params)
unless can?(current_user, :modify_merge_request_committer_setting, user_project)
params.delete(:merge_requests_disable_committers_approval)
end
unless can?(current_user, :modify_approvers_rules, user_project)
params.delete(:disable_overriding_approvers_per_merge_request)
def filter_forbidden_param!(permission, param)
unless can?(current_user, permission, user_project)
params.delete(param)
end
end
unless can?(current_user, :modify_merge_request_author_setting, user_project)
params.delete(:merge_requests_author_approval)
end
def filter_params(params)
filter_forbidden_param!(:modify_merge_request_committer_setting, :merge_requests_disable_committers_approval)
filter_forbidden_param!(:modify_approvers_rules, :disable_overriding_approvers_per_merge_request)
filter_forbidden_param!(:modify_merge_request_author_setting, :merge_requests_author_approval)
params
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