Commit 97ca4f5ddadd9f6880e238e85af00a82dcd8807f
1 parent
dfb5da9d
Exists in
master
and in
4 other branches
Deliver issue mails.
It helps to actually deliver messages.
Showing
2 changed files
with
19 additions
and
7 deletions
Show diff stats
app/models/issue_observer.rb
... | ... | @@ -2,7 +2,7 @@ class IssueObserver < ActiveRecord::Observer |
2 | 2 | cattr_accessor :current_user |
3 | 3 | |
4 | 4 | def after_create(issue) |
5 | - Notify.new_issue_email(issue.id) if issue.assignee != current_user | |
5 | + Notify.new_issue_email(issue.id).deliver if issue.assignee != current_user | |
6 | 6 | end |
7 | 7 | |
8 | 8 | def after_update(issue) |
... | ... | @@ -15,7 +15,7 @@ class IssueObserver < ActiveRecord::Observer |
15 | 15 | recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id } |
16 | 16 | |
17 | 17 | recipient_ids.each do |recipient_id| |
18 | - Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was) | |
18 | + Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver | |
19 | 19 | end |
20 | 20 | end |
21 | 21 | end | ... | ... |
spec/models/issue_observer_spec.rb
... | ... | @@ -20,7 +20,8 @@ describe IssueObserver do |
20 | 20 | end |
21 | 21 | |
22 | 22 | it 'sends an email to the assignee' do |
23 | - Notify.should_receive(:new_issue_email).with(issue.id) | |
23 | + Notify.should_receive(:new_issue_email).with(issue.id). | |
24 | + and_return(double(:deliver => true)) | |
24 | 25 | |
25 | 26 | subject.after_create(issue) |
26 | 27 | end |
... | ... | @@ -107,9 +108,18 @@ describe IssueObserver do |
107 | 108 | issue.stub(:assignee_id_was).and_return(previous_assignee.id) |
108 | 109 | end |
109 | 110 | |
111 | + def it_sends_a_reassigned_email_to(recipient) | |
112 | + Notify.should_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id). | |
113 | + and_return(double(:deliver => true)) | |
114 | + end | |
115 | + | |
116 | + def it_does_not_send_a_reassigned_email_to(recipient) | |
117 | + Notify.should_not_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id) | |
118 | + end | |
119 | + | |
110 | 120 | it 'sends a reassigned email to the previous and current assignees' do |
111 | - Notify.should_receive(:reassigned_issue_email).with(assignee.id, issue.id, previous_assignee.id) | |
112 | - Notify.should_receive(:reassigned_issue_email).with(previous_assignee.id, issue.id, previous_assignee.id) | |
121 | + it_sends_a_reassigned_email_to assignee.id | |
122 | + it_sends_a_reassigned_email_to previous_assignee.id | |
113 | 123 | |
114 | 124 | subject.send_reassigned_email(issue) |
115 | 125 | end |
... | ... | @@ -117,13 +127,15 @@ describe IssueObserver do |
117 | 127 | context 'does not send an email to the user who made the reassignment' do |
118 | 128 | it 'if the user is the assignee' do |
119 | 129 | subject.stub(:current_user).and_return(assignee) |
120 | - Notify.should_not_receive(:reassigned_issue_email).with(assignee.id, issue.id, previous_assignee.id) | |
130 | + it_sends_a_reassigned_email_to previous_assignee.id | |
131 | + it_does_not_send_a_reassigned_email_to assignee.id | |
121 | 132 | |
122 | 133 | subject.send_reassigned_email(issue) |
123 | 134 | end |
124 | 135 | it 'if the user is the previous assignee' do |
125 | 136 | subject.stub(:current_user).and_return(previous_assignee) |
126 | - Notify.should_not_receive(:reassigned_issue_email).with(previous_assignee.id, issue.id, previous_assignee.id) | |
137 | + it_sends_a_reassigned_email_to assignee.id | |
138 | + it_does_not_send_a_reassigned_email_to previous_assignee.id | |
127 | 139 | |
128 | 140 | subject.send_reassigned_email(issue) |
129 | 141 | end | ... | ... |