inslude author & assignee to note notification recipients
This commit is contained in:
parent
618249734b
commit
70947fedda
2 changed files with 60 additions and 27 deletions
|
@ -106,12 +106,14 @@ class NotificationService
|
|||
|
||||
if note.commit_id
|
||||
opts.merge!(commit_id: note.commit_id)
|
||||
recipients = [note.commit_author]
|
||||
else
|
||||
opts.merge!(noteable_id: note.noteable_id)
|
||||
recipients = [note.noteable.try(:author), note.noteable.try(:assignee)]
|
||||
end
|
||||
|
||||
# Get users who left comment in thread
|
||||
recipients = User.where(id: Note.where(opts).pluck(:author_id))
|
||||
recipients = recipients.concat(User.where(id: Note.where(opts).pluck(:author_id)))
|
||||
|
||||
# Merge project watchers
|
||||
recipients = recipients.concat(project_watchers(note.project)).compact.uniq
|
||||
|
|
|
@ -21,6 +21,36 @@ describe NotificationService do
|
|||
end
|
||||
|
||||
describe 'Notes' do
|
||||
context 'issue note' do
|
||||
let(:issue) { create(:issue, assignee: create(:user)) }
|
||||
let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id) }
|
||||
|
||||
before do
|
||||
build_team(note.project)
|
||||
end
|
||||
|
||||
describe :new_note do
|
||||
it do
|
||||
should_email(@u_watcher.id)
|
||||
should_email(note.noteable.author_id)
|
||||
should_email(note.noteable.assignee_id)
|
||||
should_not_email(note.author_id)
|
||||
should_not_email(@u_participating.id)
|
||||
should_not_email(@u_disabled.id)
|
||||
notification.new_note(note)
|
||||
end
|
||||
|
||||
def should_email(user_id)
|
||||
Notify.should_receive(:note_issue_email).with(user_id, note.id)
|
||||
end
|
||||
|
||||
def should_not_email(user_id)
|
||||
Notify.should_not_receive(:note_issue_email).with(user_id, note.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'commit note' do
|
||||
let(:note) { create :note_on_commit }
|
||||
|
||||
before do
|
||||
|
@ -58,6 +88,7 @@ describe NotificationService do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Issues' do
|
||||
let(:issue) { create :issue, assignee: create(:user) }
|
||||
|
|
Loading…
Reference in a new issue