Commit 669ada924b3d058f5ad8bfc6822b1a9e64b3549b

Authored by Javier Castro
Committed by Javier Castro
1 parent cb877b7e

Fix test case for notification_service

Showing 1 changed file with 18 additions and 18 deletions   Show diff stats
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, note: '@mention referenced') } 51 + let(:note) { create(:note_on_commit) }
52 52
53 before do 53 before do
54 build_team(note.project) 54 build_team(note.project)
@@ -56,35 +56,35 @@ describe NotificationService do @@ -56,35 +56,35 @@ describe NotificationService do
56 56
57 describe :new_note do 57 describe :new_note do
58 it do 58 it do
59 - should_email(@u_watcher.id)  
60 - should_email(@u_mentioned.id)  
61 - should_not_email(note.author_id)  
62 - should_not_email(@u_participating.id)  
63 - should_not_email(@u_disabled.id) 59 + should_email(@u_watcher.id, note)
  60 + should_not_email(@u_mentioned.id, note)
  61 + should_not_email(note.author_id, note)
  62 + should_not_email(@u_participating.id, note)
  63 + should_not_email(@u_disabled.id, note)
64 notification.new_note(note) 64 notification.new_note(note)
65 end 65 end
66 66
67 it do 67 it do
68 - create(:note_on_commit, 68 + new_note = create(:note_on_commit,
69 author: @u_participating, 69 author: @u_participating,
70 project_id: note.project_id, 70 project_id: note.project_id,
71 commit_id: note.commit_id, 71 commit_id: note.commit_id,
72 note: '@mention referenced') 72 note: '@mention referenced')
73 73
74 - should_email(@u_watcher.id)  
75 - should_email(@u_participating.id)  
76 - should_email(@u_mentioned.id)  
77 - should_not_email(note.author_id)  
78 - should_not_email(@u_disabled.id)  
79 - notification.new_note(note) 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)
80 end 80 end
81 81
82 - def should_email(user_id)  
83 - Notify.should_receive(:note_commit_email).with(user_id, note.id) 82 + def should_email(user_id, n)
  83 + Notify.should_receive(:note_commit_email).with(user_id, n.id)
84 end 84 end
85 85
86 - def should_not_email(user_id)  
87 - Notify.should_not_receive(:note_commit_email).with(user_id, note.id) 86 + def should_not_email(user_id, n)
  87 + Notify.should_not_receive(:note_commit_email).with(user_id, n.id)
88 end 88 end
89 end 89 end
90 end 90 end
@@ -239,7 +239,7 @@ describe NotificationService do @@ -239,7 +239,7 @@ describe NotificationService do
239 @u_watcher = create(:user, notification_level: Notification::N_WATCH) 239 @u_watcher = create(:user, notification_level: Notification::N_WATCH)
240 @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING) 240 @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING)
241 @u_disabled = create(:user, notification_level: Notification::N_DISABLED) 241 @u_disabled = create(:user, notification_level: Notification::N_DISABLED)
242 - @u_mentioned = create(:user, username: 'mention', notification_level: Notification::N_WATCH) 242 + @u_mentioned = create(:user, username: 'mention', notification_level: Notification::N_PARTICIPATING)
243 243
244 project.team << [@u_watcher, :master] 244 project.team << [@u_watcher, :master]
245 project.team << [@u_participating, :master] 245 project.team << [@u_participating, :master]