Commit 3a334f4b authored by Jarka Kadlecova's avatar Jarka Kadlecova

Fix count of required approvals displayed on MR edit form

parent 3d1c7fa0
......@@ -4,16 +4,14 @@
- return unless issuable.is_a?(MergeRequest)
- return unless issuable.requires_approve?
- approvals_required = issuable.target_project.approvals_before_merge
.form-group
= form.label :approvals_before_merge, class: 'control-label' do
Approvals required
.col-sm-10
= form.number_field :approvals_before_merge, class: 'form-control', value: approvals_required
= form.number_field :approvals_before_merge, class: 'form-control', value: issuable.approvals_required
.help-block
Number of users who need to approve this merge request before it can be accepted.
If this isn't greater than the project default (#{pluralize(approvals_required, 'user')}),
If this isn't greater than the project default (#{pluralize(issuable.target_project.approvals_before_merge, 'user')}),
then it will be ignored and the project default will be used.
.form-group
= form.label :approver_ids, class: 'control-label' do
......
---
title: Fix count of required approvals displayed on MR edit form
merge_request: 1082
author:
......@@ -153,6 +153,36 @@ feature 'Merge request approvals', js: true, feature: true do
find('.approvals-components')
expect(page).to have_content("Requires 1 more approval (from #{approver.name})")
end
it 'allows changing approvals number' do
create_list :approver, 3, target: project
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
# project setting in the beginning on the show MR page
find('.approvals-components')
expect(page).to have_content("Requires 1 more approval")
find('.merge-request').click_on 'Edit'
# project setting in the beginning on the edit MR page
expect(find('#merge_request_approvals_before_merge').value).to eq('1')
expect(find('#merge_request_approvals_before_merge ~ .help-block')).to have_content('1 user')
fill_in 'merge_request_approvals_before_merge', with: '3'
click_on('Save changes')
# new MR setting on the show MR page
find('.approvals-components')
expect(page).to have_content("Requires 3 more approvals")
find('.merge-request').click_on 'Edit'
# new MR setting on the edit MR page
expect(find('#merge_request_approvals_before_merge').value).to eq('3')
expect(find('#merge_request_approvals_before_merge ~ .help-block')).to have_content('1 user')
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