Commit 015c6602 authored by Mark Chao's avatar Mark Chao

Fix controller group_ids and user_ids not recognized

parent db6142a8
......@@ -32,11 +32,13 @@ module EE
params[:approval_rules_attributes].each do |rule_attributes|
if rule_attributes.key?(:group_ids)
rule_attributes[:group_ids] = rule_attributes[:group_ids] & group_ids
provided_group_ids = rule_attributes[:group_ids].map(&:to_i)
rule_attributes[:group_ids] = provided_group_ids & group_ids
end
if rule_attributes.key?(:user_ids)
rule_attributes[:user_ids] = rule_attributes[:user_ids] & user_ids
provided_user_ids = rule_attributes[:user_ids].map(&:to_i)
rule_attributes[:user_ids] = provided_user_ids & user_ids
end
end
end
......
......@@ -163,6 +163,22 @@ describe Projects::MergeRequestsController do
expect(merge_request.reload.approvals_before_merge).to eq(2)
end
it 'creates rules' do
users = create_list(:user, 3)
users.each { |user| project.add_developer(user) }
update_merge_request(approval_rules_attributes: [
{ name: 'foo', user_ids: users.map(&:id), approvals_required: 3 }
])
expect(merge_request.reload.approval_rules.size).to eq(1)
rule = merge_request.reload.approval_rules.first
expect(rule.name).to eq('foo')
expect(rule.approvals_required).to eq(3)
end
end
context 'disabled' do
......
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