Commit f4f0a7e03e64e3fffb9b14ba5583e2c6b7c6441b
1 parent
69432c88
Exists in
spb-stable
and in
3 other branches
Add a failing test.
Showing
1 changed file
with
31 additions
and
4 deletions
Show diff stats
spec/services/notification_service_spec.rb
| ... | ... | @@ -57,15 +57,42 @@ describe NotificationService do |
| 57 | 57 | Notify.should_not_receive(:note_issue_email) |
| 58 | 58 | notification.new_note(mentioned_note) |
| 59 | 59 | end |
| 60 | + end | |
| 60 | 61 | |
| 61 | - def should_email(user_id) | |
| 62 | - Notify.should_receive(:note_issue_email).with(user_id, note.id) | |
| 62 | + describe 'new note on issue in project that belongs to a group' do | |
| 63 | + let(:group) { create(:group) } | |
| 64 | + | |
| 65 | + before do | |
| 66 | + note.project.namespace_id = group.id | |
| 67 | + note.project.group.add_user(@u_watcher, UsersGroup::MASTER) | |
| 68 | + note.project.save | |
| 69 | + user_project = note.project.users_projects.find_by_user_id(@u_watcher.id) | |
| 70 | + user_project.notification_level = Notification::N_PARTICIPATING | |
| 71 | + user_project.save | |
| 72 | + user_group = note.project.group.users_groups.find_by_user_id(@u_watcher.id) | |
| 73 | + user_group.notification_level = Notification::N_GLOBAL | |
| 74 | + user_group.save | |
| 63 | 75 | end |
| 64 | 76 | |
| 65 | - def should_not_email(user_id) | |
| 66 | - Notify.should_not_receive(:note_issue_email).with(user_id, note.id) | |
| 77 | + it do | |
| 78 | + should_email(note.noteable.author_id) | |
| 79 | + should_email(note.noteable.assignee_id) | |
| 80 | + should_email(@u_mentioned.id) | |
| 81 | + should_not_email(@u_watcher.id) | |
| 82 | + should_not_email(note.author_id) | |
| 83 | + should_not_email(@u_participating.id) | |
| 84 | + should_not_email(@u_disabled.id) | |
| 85 | + notification.new_note(note) | |
| 67 | 86 | end |
| 68 | 87 | end |
| 88 | + | |
| 89 | + def should_email(user_id) | |
| 90 | + Notify.should_receive(:note_issue_email).with(user_id, note.id) | |
| 91 | + end | |
| 92 | + | |
| 93 | + def should_not_email(user_id) | |
| 94 | + Notify.should_not_receive(:note_issue_email).with(user_id, note.id) | |
| 95 | + end | |
| 69 | 96 | end |
| 70 | 97 | |
| 71 | 98 | context 'commit note' do | ... | ... |