Commit 94764057 authored by Kerri Miller's avatar Kerri Miller

Drop system notes filter and use basic scope

parent fcea425c
......@@ -73,15 +73,8 @@ module Issuable
end
end
has_many :note_authors, -> { distinct }, through: :notes, source: :author do
def user_notes
where("notes.system = false")
end
def system_notes
where("notes.system = true")
end
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
......
......@@ -29,27 +29,18 @@ RSpec.describe Issuable do
end
describe 'note_authors' do
let(:system_user) { create(:user) }
let!(:system_note) { create(:system_note, author: system_user, noteable: issue, project: issue.project) }
it { is_expected.to have_many(:note_authors).through(:notes) }
end
describe 'note_authors.user_notes' do
it 'filters the authors to those of user notes' do
authors = issue.note_authors.user_notes
expect(authors).to include(note.author)
expect(authors).not_to include(system_user)
end
end
describe 'user_note_authors' do
let(:system_user) { create(:user) }
let!(:system_note) { create(:system_note, author: system_user, noteable: issue, project: issue.project) }
describe 'note_authors.system_notes' do
it 'filters the authors to those of system notes' do
authors = issue.note_authors.system_notes
it 'filters the authors to those of user notes' do
authors = issue.user_note_authors
expect(authors).to include(system_user)
expect(authors).not_to include(note.author)
end
expect(authors).to include(note.author)
expect(authors).not_to include(system_user)
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