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