diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-28 12:24:04 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-28 12:24:04 +0200 |
commit | c04120c1c512bd515fceccc70d0c7cf0a6bf4cb7 (patch) | |
tree | eff0b7eb71fc6d409010ee6118a60654558050e4 | |
parent | f49a2ac0df978eaf897a8c8b28a202ae9a01165f (diff) | |
download | gitlab-ce-c04120c1c512bd515fceccc70d0c7cf0a6bf4cb7.tar.gz |
Improve notification service tests
-rw-r--r-- | app/mailers/emails/issues.rb | 2 | ||||
-rw-r--r-- | app/services/notification_service.rb | 2 | ||||
-rw-r--r-- | spec/services/notification_service_spec.rb | 29 |
3 files changed, 22 insertions, 11 deletions
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index dc0381f540a..74114ffd4de 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -13,7 +13,7 @@ module Emails mail(to: recipient(recipient_id), subject: subject("changed issue ##{@issue.id}", @issue.title)) end - def close_issue_email(recipient_id, issue_id, updated_by_user_id) + def closed_issue_email(recipient_id, issue_id, updated_by_user_id) @issue = Issue.find issue_id @project = @issue.project @updated_by = User.find updated_by_user_id diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index c53a6cc5c19..a9978a95f79 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -33,7 +33,7 @@ class NotificationService # * project team members with notification level higher then Participating # def close_issue(issue, current_user) - close_resource_email(issue, current_user, 'close_issue_email') + close_resource_email(issue, current_user, 'closed_issue_email') end # When we reassign an issue we should send next emails: diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 0c6c014429b..e818277d447 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -28,9 +28,20 @@ describe NotificationService do end describe :new_issue do - it 'should sent email to issue assignee' do - Notify.should_receive(:new_issue_email).with(issue.id) - notification.new_issue(issue, nil) + it do + should_email(issue.assignee_id) + should_email(@u_watcher.id) + should_not_email(@u_participating.id) + should_not_email(@u_disabled.id) + notification.new_issue(issue, @u_disabled) + end + + def should_email(user_id) + Notify.should_receive(:new_issue_email).with(user_id, issue.id) + end + + def should_not_email(user_id) + Notify.should_not_receive(:new_issue_email).with(user_id, issue.id) end end @@ -65,11 +76,11 @@ describe NotificationService do end def should_email(user_id) - Notify.should_receive(:closed_issue_email).with(user_id, issue.id, issue.assignee_id) + Notify.should_receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id) end def should_not_email(user_id) - Notify.should_not_receive(:closed_issue_email).with(user_id, issue.id, issue.assignee_id) + Notify.should_not_receive(:closed_issue_email).with(user_id, issue.id, @u_disabled.id) end end end @@ -91,11 +102,11 @@ describe NotificationService do end def should_email(user_id) - Notify.should_receive(:new_merge_request_email).with(merge_request.id) + Notify.should_receive(:new_merge_request_email).with(user_id, merge_request.id) end def should_not_email(user_id) - Notify.should_not_receive(:new_merge_request_email).with(merge_request.id) + Notify.should_not_receive(:new_merge_request_email).with(user_id, merge_request.id) end end @@ -127,11 +138,11 @@ describe NotificationService do end def should_email(user_id) - Notify.should_receive(:closed_merge_request_email).with(user_id, merge_request.id) + Notify.should_receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id) end def should_not_email(user_id) - Notify.should_not_receive(:closed_merge_request_email).with(user_id, merge_request.id) + Notify.should_not_receive(:closed_merge_request_email).with(user_id, merge_request.id, @u_disabled.id) end end |