Commit 4667da3c authored by Igor Drozdov's avatar Igor Drozdov

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

Add data to commented_by field

See merge request gitlab-org/gitlab!39237
parents c2629e66 92f374a1
......@@ -61,6 +61,8 @@ module Issuable
end
end
has_many :note_authors, -> { distinct }, through: :notes, source: :author
has_many :label_links, as: :target, dependent: :destroy, inverse_of: :target # rubocop:disable Cop/ActiveRecordDependent
has_many :labels, through: :label_links
has_many :todos, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
......
......@@ -76,7 +76,7 @@ class ApprovalWrappedRule
def commented_approvers
strong_memoize(:commented_approvers) do
[]
merge_request.note_authors & approvers
end
end
......
---
title: Add commented_by to approval_settings endpoint
merge_request: 39237
author:
type: added
......@@ -139,9 +139,17 @@ RSpec.describe ApprovalWrappedRule do
end
describe "#commented_approvers" do
let(:rule) { create(:approval_project_rule, project: merge_request.project, approvals_required: approvals_required, users: [approver1, approver3]) }
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)
expect(subject.commented_approvers).to eq([approver1])
end
end
describe '#unactioned_approvers' do
......
......@@ -47,6 +47,7 @@ issues:
- alert_management_alert
- status_page_published_incident
- namespace
- note_authors
events:
- author
- project
......@@ -167,6 +168,7 @@ merge_requests:
- deployments
- user_mentions
- system_note_metadata
- note_authors
external_pull_requests:
- project
merge_request_diff:
......@@ -671,6 +673,7 @@ epic:
- events
- resource_label_events
- user_mentions
- note_authors
epic_issue:
- epic
- issue
......
......@@ -17,6 +17,7 @@ RSpec.describe Issuable do
it { is_expected.to have_many(:notes).dependent(:destroy) }
it { is_expected.to have_many(:todos).dependent(:destroy) }
it { is_expected.to have_many(:labels) }
it { is_expected.to have_many(:note_authors).through(:notes) }
context 'Notes' do
let!(:note) { create(:note, noteable: issue, project: issue.project) }
......
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