Commit 1a07dc7e authored by Tiago Botelho's avatar Tiago Botelho

Pushing to a merge request clears the approvals list if the respective project setting is enabled

Previously if the project had approvals_before_merge setting at 0
the approvals would not be cleared even if the "Pushing to a merge
request clears approvals" project setting was enabled.

This commit removes the approvals_before_merge out of the check of
whether we should or not reset the merge request approvals.
parent afb9586b
...@@ -18,8 +18,7 @@ module EE ...@@ -18,8 +18,7 @@ module EE
merge_requests.each do |merge_request| merge_requests.each do |merge_request|
target_project = merge_request.target_project target_project = merge_request.target_project
if target_project.approvals_before_merge.nonzero? && if target_project.reset_approvals_on_push &&
target_project.reset_approvals_on_push &&
merge_request.rebase_commit_sha != newrev merge_request.rebase_commit_sha != newrev
merge_request.approvals.delete_all merge_request.approvals.delete_all
......
...@@ -38,9 +38,7 @@ module EE ...@@ -38,9 +38,7 @@ module EE
def reset_approvals(merge_request) def reset_approvals(merge_request)
target_project = merge_request.target_project target_project = merge_request.target_project
if target_project.approvals_before_merge.nonzero? && target_project.reset_approvals_on_push merge_request.approvals.delete_all if target_project.reset_approvals_on_push
merge_request.approvals.delete_all
end
end end
end end
end end
......
---
title: Pushing to a merge request clears the approvals list even if the respective project
setting is enabled and there is no fixed required number of approvals configured
merge_request: 7328
author:
type: fixed
...@@ -354,8 +354,8 @@ describe MergeRequests::RefreshService do ...@@ -354,8 +354,8 @@ describe MergeRequests::RefreshService do
reload_mrs reload_mrs
end end
it 'does not reset approvals' do it 'resets approvals' do
expect(@merge_request.approvals).not_to be_empty expect(@merge_request.approvals).to be_empty
end end
end end
......
...@@ -578,7 +578,7 @@ describe MergeRequests::UpdateService, :mailer do ...@@ -578,7 +578,7 @@ describe MergeRequests::UpdateService, :mailer do
context 'updating target_branch' do context 'updating target_branch' do
it 'resets approvals when target_branch is changed' do it 'resets approvals when target_branch is changed' do
merge_request.target_project.update(reset_approvals_on_push: true, approvals_before_merge: 2) merge_request.target_project.update(reset_approvals_on_push: true)
merge_request.approvals.create(user_id: user2.id) merge_request.approvals.create(user_id: user2.id)
update_merge_request(target_branch: 'video') update_merge_request(target_branch: 'video')
......
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