Commit 1cadf027 authored by Kerri Miller's avatar Kerri Miller

Merge branch '353387-add-user-and-system-note-filters-to-note_authors-association' into 'master'

Add user and system note filters to note_authors association

See merge request gitlab-org/gitlab!81436
parents 9c103767 4090b6de
......@@ -74,6 +74,7 @@ module Issuable
end
has_many :note_authors, -> { distinct }, through: :notes, source: :author
has_many :user_note_authors, -> { distinct.where("notes.system = false") }, through: :notes, source: :author
has_many :label_links, as: :target, inverse_of: :target
has_many :labels, through: :label_links
......
......@@ -55,6 +55,7 @@ issues:
- status_page_published_incident
- namespace
- note_authors
- user_note_authors
- issue_email_participants
- test_reports
- requirement
......@@ -200,6 +201,7 @@ merge_requests:
- user_mentions
- system_note_metadata
- note_authors
- user_note_authors
- cleanup_schedule
- compliance_violations
external_pull_requests:
......@@ -774,6 +776,7 @@ epic:
- resource_state_events
- user_mentions
- note_authors
- user_note_authors
- boards_epic_user_preferences
- epic_board_positions
epic_issue:
......
......@@ -18,7 +18,6 @@ RSpec.describe Issuable do
it { is_expected.to have_many(:notes).dependent(:destroy) }
it { is_expected.to have_many(:todos) }
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) }
......@@ -28,6 +27,23 @@ RSpec.describe Issuable do
expect(issue.notes).not_to be_authors_loaded
expect(scoped_issue.notes).to be_authors_loaded
end
describe 'note_authors' do
it { is_expected.to have_many(:note_authors).through(:notes) }
end
describe 'user_note_authors' do
let_it_be(:system_user) { create(:user) }
let!(:system_note) { create(:system_note, author: system_user, noteable: issue, project: issue.project) }
it 'filters the authors to those of user notes' do
authors = issue.user_note_authors
expect(authors).to include(note.author)
expect(authors).not_to include(system_user)
end
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