diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-28 14:51:25 +0200 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-28 14:51:25 +0200 |
| commit | 70947fedda4f955f69d928ad0309b3f042056582 (patch) | |
| tree | 849ea86bc328dafba15552a2de2f322d7f474d4d /spec | |
| parent | 618249734b1bcb8886b9d96714d278119037261c (diff) | |
| download | gitlab-ce-70947fedda4f955f69d928ad0309b3f042056582.tar.gz | |
inslude author & assignee to note notification recipients
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/services/notification_service_spec.rb | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index c82b89d65d9..fa47a6354c8 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -21,40 +21,71 @@ describe NotificationService do end describe 'Notes' do - let(:note) { create :note_on_commit } + context 'issue note' do + let(:issue) { create(:issue, assignee: create(:user)) } + let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id) } - before do - build_team(note.project) - end - - describe :new_note do - it do - should_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) + before do + build_team(note.project) end - it do - create(:note_on_commit, - author: @u_participating, - project_id: note.project_id, - commit_id: note.commit_id) + describe :new_note do + it do + should_email(@u_watcher.id) + should_email(note.noteable.author_id) + should_email(note.noteable.assignee_id) + should_not_email(note.author_id) + should_not_email(@u_participating.id) + should_not_email(@u_disabled.id) + notification.new_note(note) + end - should_email(@u_watcher.id) - should_email(@u_participating.id) - should_not_email(note.author_id) - should_not_email(@u_disabled.id) - notification.new_note(note) - end + def should_email(user_id) + Notify.should_receive(:note_issue_email).with(user_id, note.id) + end - def should_email(user_id) - Notify.should_receive(:note_commit_email).with(user_id, note.id) + def should_not_email(user_id) + Notify.should_not_receive(:note_issue_email).with(user_id, note.id) + end end + end - def should_not_email(user_id) - Notify.should_not_receive(:note_commit_email).with(user_id, note.id) + context 'commit note' do + let(:note) { create :note_on_commit } + + before do + build_team(note.project) + end + + describe :new_note do + it do + should_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 + + it do + create(:note_on_commit, + author: @u_participating, + project_id: note.project_id, + commit_id: note.commit_id) + + should_email(@u_watcher.id) + should_email(@u_participating.id) + should_not_email(note.author_id) + should_not_email(@u_disabled.id) + notification.new_note(note) + end + + def should_email(user_id) + Notify.should_receive(:note_commit_email).with(user_id, note.id) + end + + def should_not_email(user_id) + Notify.should_not_receive(:note_commit_email).with(user_id, note.id) + end end end end |
