Commit f45cb1d7 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch...

Merge branch '1961-number-of-required-approvals-must-not-be-reset-when-changing-assignee' into 'master'

Resolve "Number of required approvals MUST NOT be reset when changing assignee"

Closes #1961

See merge request !1515
parents ae2df96b 13ea07f4
......@@ -751,12 +751,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
]
end
# If the number of approvals is not greater than the project default, set to
# nil, so that we fall back to the project default. If it's not set, we can
# let the normal update logic handle this.
def clamp_approvals_before_merge(mr_params)
return mr_params unless mr_params[:approvals_before_merge]
target_project = @project.forked_from_project if @project.id.to_s != mr_params[:target_project_id]
target_project ||= @project
# If the number of approvals is not greater than the project default, set to nil,
# so that we fall back to the project default.
if mr_params[:approvals_before_merge].to_i <= target_project.approvals_before_merge
mr_params[:approvals_before_merge] = nil
end
......
---
title: Fix approver count reset when editing assignee or labels
merge_request:
author:
......@@ -488,7 +488,24 @@ describe Projects::MergeRequestsController do
end
context 'approvals_before_merge set for the existing MR' do
before { merge_request.update_attribute(:approvals_before_merge, 4) }
before do
merge_request.update_attribute(:approvals_before_merge, 4)
end
context 'when it is not set' do
before do
update_merge_request(title: 'New title')
end
it 'does not change the merge request' do
expect(merge_request.reload.approvals_before_merge).to eq(4)
end
it 'updates the merge request' do
expect(merge_request.reload).to be_valid
expect(response).to redirect_to(namespace_project_merge_request_path(id: merge_request.iid, project_id: project.to_param))
end
end
context 'when it is less than the one in the target project' do
before { update_merge_request(approvals_before_merge: 1) }
......
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