Commit 0f1ea152 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'commented-by-4' into 'master'

Fix commented_by for any approver rule

Closes #235884

See merge request gitlab-org/gitlab!39432
parents 6b235dc4 274d9a74
......@@ -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