Commit 669ada924b3d058f5ad8bfc6822b1a9e64b3549b
Committed by
Javier Castro
1 parent
cb877b7e
Exists in
master
and in
4 other branches
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 | 48 | end |
49 | 49 | |
50 | 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 | 53 | before do |
54 | 54 | build_team(note.project) |
... | ... | @@ -56,35 +56,35 @@ describe NotificationService do |
56 | 56 | |
57 | 57 | describe :new_note do |
58 | 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 | 64 | notification.new_note(note) |
65 | 65 | end |
66 | 66 | |
67 | 67 | it do |
68 | - create(:note_on_commit, | |
68 | + new_note = create(:note_on_commit, | |
69 | 69 | author: @u_participating, |
70 | 70 | project_id: note.project_id, |
71 | 71 | commit_id: note.commit_id, |
72 | 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 | 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 | 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 | 88 | end |
89 | 89 | end |
90 | 90 | end |
... | ... | @@ -239,7 +239,7 @@ describe NotificationService do |
239 | 239 | @u_watcher = create(:user, notification_level: Notification::N_WATCH) |
240 | 240 | @u_participating = create(:user, notification_level: Notification::N_PARTICIPATING) |
241 | 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 | 244 | project.team << [@u_watcher, :master] |
245 | 245 | project.team << [@u_participating, :master] | ... | ... |