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,7 +2,7 @@ class IssueObserver < ActiveRecord::Observer | ||
2 | cattr_accessor :current_user | 2 | cattr_accessor :current_user |
3 | 3 | ||
4 | def after_create(issue) | 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 | end | 6 | end |
7 | 7 | ||
8 | def after_update(issue) | 8 | def after_update(issue) |
@@ -15,7 +15,7 @@ class IssueObserver < ActiveRecord::Observer | @@ -15,7 +15,7 @@ class IssueObserver < ActiveRecord::Observer | ||
15 | recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id } | 15 | recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id } |
16 | 16 | ||
17 | recipient_ids.each do |recipient_id| | 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 | end | 19 | end |
20 | end | 20 | end |
21 | end | 21 | end |
spec/models/issue_observer_spec.rb
@@ -20,7 +20,8 @@ describe IssueObserver do | @@ -20,7 +20,8 @@ describe IssueObserver do | ||
20 | end | 20 | end |
21 | 21 | ||
22 | it 'sends an email to the assignee' do | 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 | subject.after_create(issue) | 26 | subject.after_create(issue) |
26 | end | 27 | end |
@@ -107,9 +108,18 @@ describe IssueObserver do | @@ -107,9 +108,18 @@ describe IssueObserver do | ||
107 | issue.stub(:assignee_id_was).and_return(previous_assignee.id) | 108 | issue.stub(:assignee_id_was).and_return(previous_assignee.id) |
108 | end | 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 | it 'sends a reassigned email to the previous and current assignees' do | 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 | subject.send_reassigned_email(issue) | 124 | subject.send_reassigned_email(issue) |
115 | end | 125 | end |
@@ -117,13 +127,15 @@ describe IssueObserver do | @@ -117,13 +127,15 @@ describe IssueObserver do | ||
117 | context 'does not send an email to the user who made the reassignment' do | 127 | context 'does not send an email to the user who made the reassignment' do |
118 | it 'if the user is the assignee' do | 128 | it 'if the user is the assignee' do |
119 | subject.stub(:current_user).and_return(assignee) | 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 | subject.send_reassigned_email(issue) | 133 | subject.send_reassigned_email(issue) |
123 | end | 134 | end |
124 | it 'if the user is the previous assignee' do | 135 | it 'if the user is the previous assignee' do |
125 | subject.stub(:current_user).and_return(previous_assignee) | 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 | subject.send_reassigned_email(issue) | 140 | subject.send_reassigned_email(issue) |
129 | end | 141 | end |