Commit 274d9a74 authored by Robert May's avatar Robert May Committed by Igor Drozdov

Fix commented_by for any approver rule

Fixes https://gitlab.com/gitlab-org/gitlab/-/issues/235884.
parent 4dddd904
......@@ -15,4 +15,12 @@ class ApprovalWrappedAnyApproverRule < ApprovalWrappedRule
approvals_left <= 0
end
end
def commented_approvers
strong_memoize(:commented_approvers) do
merge_request.note_authors.select do |user|
merge_request.can_approve?(user)
end
end
end
end
---
title: Fix commented_by for any approvers rule
merge_request: 39432
author:
type: fixed
......@@ -47,4 +47,18 @@ RSpec.describe ApprovalWrappedAnyApproverRule do
it '#approved?' do
expect(subject.approved?).to eq(true)
end
describe "#commented_approvers" do
it "returns an array" do
expect(subject.commented_approvers).to be_an(Array)
end
it "returns an array of approvers who have commented" do
create(:note, project: merge_request.project, noteable: merge_request, author: approver1)
allow(merge_request).to receive(:can_approve?).with(approver1).and_return(true)
expect(subject.commented_approvers).to eq([approver1])
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