Commit cb877b7e6f6b036a2811aec7313dab94473774de
1 parent
707cea8d
Exists in
master
and in
4 other branches
Fix notifications to handle participants and mentions on commits too
Showing
2 changed files
with
12 additions
and
9 deletions
Show diff stats
app/services/notification_service.rb
@@ -106,15 +106,15 @@ class NotificationService | @@ -106,15 +106,15 @@ class NotificationService | ||
106 | 106 | ||
107 | if note.commit_id.present? | 107 | if note.commit_id.present? |
108 | opts.merge!(commit_id: note.commit_id) | 108 | opts.merge!(commit_id: note.commit_id) |
109 | - recipients = [note.commit_author] | ||
110 | else | 109 | else |
111 | opts.merge!(noteable_id: note.noteable_id) | 110 | opts.merge!(noteable_id: note.noteable_id) |
112 | - target = note.noteable | ||
113 | - if target.respond_to?(:participants) | ||
114 | - recipients = target.participants | ||
115 | - else | ||
116 | - recipients = [] | ||
117 | - end | 111 | + end |
112 | + | ||
113 | + target = note.noteable | ||
114 | + if target.respond_to?(:participants) | ||
115 | + recipients = target.participants | ||
116 | + else | ||
117 | + recipients = note.mentioned_users | ||
118 | end | 118 | end |
119 | 119 | ||
120 | # Get users who left comment in thread | 120 | # Get users who left comment in thread |
spec/services/notification_service_spec.rb
@@ -48,7 +48,7 @@ describe NotificationService do | @@ -48,7 +48,7 @@ describe NotificationService do | ||
48 | end | 48 | end |
49 | 49 | ||
50 | context 'commit note' do | 50 | context 'commit note' do |
51 | - let(:note) { create :note_on_commit } | 51 | + let(:note) { create(:note_on_commit, note: '@mention referenced') } |
52 | 52 | ||
53 | before do | 53 | before do |
54 | build_team(note.project) | 54 | build_team(note.project) |
@@ -57,6 +57,7 @@ describe NotificationService do | @@ -57,6 +57,7 @@ describe NotificationService do | ||
57 | describe :new_note do | 57 | describe :new_note do |
58 | it do | 58 | it do |
59 | should_email(@u_watcher.id) | 59 | should_email(@u_watcher.id) |
60 | + should_email(@u_mentioned.id) | ||
60 | should_not_email(note.author_id) | 61 | should_not_email(note.author_id) |
61 | should_not_email(@u_participating.id) | 62 | should_not_email(@u_participating.id) |
62 | should_not_email(@u_disabled.id) | 63 | should_not_email(@u_disabled.id) |
@@ -67,10 +68,12 @@ describe NotificationService do | @@ -67,10 +68,12 @@ describe NotificationService do | ||
67 | create(:note_on_commit, | 68 | create(:note_on_commit, |
68 | author: @u_participating, | 69 | author: @u_participating, |
69 | project_id: note.project_id, | 70 | project_id: note.project_id, |
70 | - commit_id: note.commit_id) | 71 | + commit_id: note.commit_id, |
72 | + note: '@mention referenced') | ||
71 | 73 | ||
72 | should_email(@u_watcher.id) | 74 | should_email(@u_watcher.id) |
73 | should_email(@u_participating.id) | 75 | should_email(@u_participating.id) |
76 | + should_email(@u_mentioned.id) | ||
74 | should_not_email(note.author_id) | 77 | should_not_email(note.author_id) |
75 | should_not_email(@u_disabled.id) | 78 | should_not_email(@u_disabled.id) |
76 | notification.new_note(note) | 79 | notification.new_note(note) |