Commit 480b6f8d authored by Igor's avatar Igor Committed by Michael Kozono

Do not allow approve if author is committer

This commit fixes the case when author is a committer
If merge request approvals are disabled for an author
then Approve button should be hidden for the author
parent d7933637
......@@ -140,8 +140,8 @@ class ApprovalState
return false if approvals.where(user: user).any?
# At this point, follow self-approval rules. Otherwise authors must
# have been in the list of unactioned_approvers to have been approved.
return committers_can_approve? if merge_request.committers.include?(user)
return authors_can_approve? if merge_request.author == user
return false if !authors_can_approve? && merge_request.author == user
return false if !committers_can_approve? && merge_request.committers.include?(user)
true
end
......
---
title: Fix preventing approval of merge requests by an author
merge_request: 11263
author:
type: fixed
......@@ -608,10 +608,10 @@ describe ApprovalState do
expect(subject.can_approve?(user)).to be_truthy
end
it 'allows the user to approve the MR if not within the approvers list' do
it 'does not allow the user to approve the MR if not within the approvers list' do
allow(subject).to receive(:approvers).and_return([])
expect(subject.can_approve?(user)).to be_truthy
expect(subject.can_approve?(user)).to be_falsey
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