Commit 996d146cbd6987d54bc720550b96aacd90c2982a

Authored by Jakub Zienkiewicz
1 parent 5ff79f94

test if commit author receives new note notifications

Showing 1 changed file with 12 additions and 12 deletions   Show diff stats
spec/services/notification_service_spec.rb
@@ -52,10 +52,12 @@ describe NotificationService do @@ -52,10 +52,12 @@ describe NotificationService do
52 52
53 before do 53 before do
54 build_team(note.project) 54 build_team(note.project)
  55 + note.stub(:commit_author => @u_committer)
55 end 56 end
56 57
57 describe :new_note do 58 describe :new_note do
58 it do 59 it do
  60 + should_email(@u_committer.id, note)
59 should_email(@u_watcher.id, note) 61 should_email(@u_watcher.id, note)
60 should_not_email(@u_mentioned.id, note) 62 should_not_email(@u_mentioned.id, note)
61 should_not_email(note.author_id, note) 63 should_not_email(note.author_id, note)
@@ -65,18 +67,14 @@ describe NotificationService do @@ -65,18 +67,14 @@ describe NotificationService do
65 end 67 end
66 68
67 it do 69 it do
68 - new_note = create(:note_on_commit,  
69 - author: @u_participating,  
70 - project_id: note.project_id,  
71 - commit_id: note.commit_id,  
72 - note: '@mention referenced')  
73 -  
74 - should_email(@u_watcher.id, new_note)  
75 - should_email(@u_mentioned.id, new_note)  
76 - should_not_email(new_note.author_id, new_note)  
77 - should_not_email(@u_participating.id, new_note)  
78 - should_not_email(@u_disabled.id, new_note)  
79 - notification.new_note(new_note) 70 + note.update_attribute(:note, '@mention referenced')
  71 + should_email(@u_committer.id, note)
  72 + should_email(@u_watcher.id, note)
  73 + should_email(@u_mentioned.id, note)
  74 + should_not_email(note.author_id, note)
  75 + should_not_email(@u_participating.id, note)
  76 + should_not_email(@u_disabled.id, note)
  77 + notification.new_note(note)
80 end 78 end
81 79
82 def should_email(user_id, n) 80 def should_email(user_id, n)
@@ -240,10 +238,12 @@ describe NotificationService do @@ -240,10 +238,12 @@ describe NotificationService do
240 @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING) 238 @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING)
241 @u_disabled = create(:user, notification_level: Notification::N_DISABLED) 239 @u_disabled = create(:user, notification_level: Notification::N_DISABLED)
242 @u_mentioned = create(:user, username: 'mention', notification_level: Notification::N_PARTICIPATING) 240 @u_mentioned = create(:user, username: 'mention', notification_level: Notification::N_PARTICIPATING)
  241 + @u_committer = create(:user, username: 'committer')
243 242
244 project.team << [@u_watcher, :master] 243 project.team << [@u_watcher, :master]
245 project.team << [@u_participating, :master] 244 project.team << [@u_participating, :master]
246 project.team << [@u_disabled, :master] 245 project.team << [@u_disabled, :master]
247 project.team << [@u_mentioned, :master] 246 project.team << [@u_mentioned, :master]
  247 + project.team << [@u_committer, :master]
248 end 248 end
249 end 249 end