summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-03-28 17:15:58 +0100
committerMarin Jankovski <marin@gitlab.com>2014-04-01 17:18:52 +0200
commitf4f0a7e03e64e3fffb9b14ba5583e2c6b7c6441b (patch)
treeb326912527d133acf2b86c28b8887e8a61e15720 /spec/services
parent69432c885c7f77489c2b3a3cf118c7622647ac9b (diff)
downloadgitlab-ce-f4f0a7e03e64e3fffb9b14ba5583e2c6b7c6441b.tar.gz
Add a failing test.
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/notification_service_spec.rb35
1 files changed, 31 insertions, 4 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index fbd73a7086f..0c25f7a71d0 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -57,15 +57,42 @@ describe NotificationService do
Notify.should_not_receive(:note_issue_email)
notification.new_note(mentioned_note)
end
+ end
- def should_email(user_id)
- Notify.should_receive(:note_issue_email).with(user_id, note.id)
+ describe 'new note on issue in project that belongs to a group' do
+ let(:group) { create(:group) }
+
+ before do
+ note.project.namespace_id = group.id
+ note.project.group.add_user(@u_watcher, UsersGroup::MASTER)
+ note.project.save
+ user_project = note.project.users_projects.find_by_user_id(@u_watcher.id)
+ user_project.notification_level = Notification::N_PARTICIPATING
+ user_project.save
+ user_group = note.project.group.users_groups.find_by_user_id(@u_watcher.id)
+ user_group.notification_level = Notification::N_GLOBAL
+ user_group.save
end
- def should_not_email(user_id)
- Notify.should_not_receive(:note_issue_email).with(user_id, note.id)
+ it do
+ should_email(note.noteable.author_id)
+ should_email(note.noteable.assignee_id)
+ should_email(@u_mentioned.id)
+ should_not_email(@u_watcher.id)
+ should_not_email(note.author_id)
+ should_not_email(@u_participating.id)
+ should_not_email(@u_disabled.id)
+ notification.new_note(note)
end
end
+
+ def should_email(user_id)
+ Notify.should_receive(:note_issue_email).with(user_id, note.id)
+ end
+
+ def should_not_email(user_id)
+ Notify.should_not_receive(:note_issue_email).with(user_id, note.id)
+ end
end
context 'commit note' do