Commit 9bd447fb authored by Lucas Charles's avatar Lucas Charles Committed by Douglas Barbosa Alexandre

Drop default rule_type when creating project approval rules

Project approval rules already have a default column `rule_type` set &
shouldn't require an explicit one.

This actually interferes with `ApprovalRules::CreateService` which
assumes an explicitly passed `rule_type` should be set by using a
`#reverse_merge`.  By dropping the forced default we can roll out a more
gradual frontend update to trigger this behavior rather than require
changes on both the backend and frontend
parent efe4ff67
...@@ -29,7 +29,7 @@ module API ...@@ -29,7 +29,7 @@ module API
params do params do
requires :name, type: String, desc: 'The name of the approval rule' requires :name, type: String, desc: 'The name of the approval rule'
requires :approvals_required, type: Integer, desc: 'The number of required approvals for this rule' requires :approvals_required, type: Integer, desc: 'The number of required approvals for this rule'
optional :rule_type, type: String, desc: 'The type of approval rule', default: 'regular' optional :rule_type, type: String, desc: 'The type of approval rule'
optional :users, as: :user_ids, type: Array, coerce_with: ARRAY_COERCION_LAMBDA, desc: 'The user ids for this rule' optional :users, as: :user_ids, type: Array, coerce_with: ARRAY_COERCION_LAMBDA, desc: 'The user ids for this rule'
optional :groups, as: :group_ids, type: Array, coerce_with: ARRAY_COERCION_LAMBDA, desc: 'The group ids for this rule' optional :groups, as: :group_ids, type: Array, coerce_with: ARRAY_COERCION_LAMBDA, desc: 'The group ids for this rule'
end end
......
...@@ -133,6 +133,14 @@ describe API::ProjectApprovalRules do ...@@ -133,6 +133,14 @@ describe API::ProjectApprovalRules do
expect(json_response.symbolize_keys).to include(params) expect(json_response.symbolize_keys).to include(params)
end end
it 'sets rule_type as report_approver if name matches default name for security reports' do
expect do
post api(url, current_user), params: params.merge(name: ApprovalProjectRule::DEFAULT_NAME_FOR_SECURITY_REPORT)
end.to change { ApprovalProjectRule.report_approver.count }.from(0).to(1)
expect(response).to have_gitlab_http_status(201)
end
end end
end 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