Commit a3937f820f5e2de0a0ce812931444b025989ab6d
1 parent
56f3aee2
Exists in
theme-brasil-digital-from-staging
and in
4 other branches
Fix task mailer tests
Showing
2 changed files
with
7 additions
and
7 deletions
Show diff stats
app/mailers/task_mailer.rb
... | ... | @@ -14,7 +14,7 @@ class TaskMailer < ApplicationMailer |
14 | 14 | mail( |
15 | 15 | to: task.target.notification_emails.compact, |
16 | 16 | from: self.class.generate_from(task), |
17 | - subject: "[%s] %s" % [task.environment.name, task.target_notification_description] | |
17 | + subject: "[%s] %s" % [self.environment.name, task.target_notification_description] | |
18 | 18 | ) |
19 | 19 | end |
20 | 20 | |
... | ... | @@ -27,7 +27,7 @@ class TaskMailer < ApplicationMailer |
27 | 27 | mail( |
28 | 28 | to: task.friend_email, |
29 | 29 | from: self.class.generate_from(task), |
30 | - subject: '[%s] %s' % [ task.requestor.environment.name, task.target_notification_description ] | |
30 | + subject: '[%s] %s' % [ self.environment.name, task.target_notification_description ] | |
31 | 31 | ) |
32 | 32 | end |
33 | 33 | |
... | ... | @@ -38,14 +38,14 @@ class TaskMailer < ApplicationMailer |
38 | 38 | |
39 | 39 | @message = extract_message(task.send("#{name}_message")) |
40 | 40 | @requestor = task.requestor.name |
41 | - @url = url_for(:host => task.requestor.environment.default_hostname, :controller => 'home') | |
41 | + @url = url_for(:host => self.environment.default_hostname, :controller => 'home') | |
42 | 42 | |
43 | 43 | mail_with_template( |
44 | 44 | to: task.requestor.notification_emails, |
45 | 45 | from: self.class.generate_from(task), |
46 | - subject: '[%s] %s' % [task.requestor.environment.name, task.target_notification_description], | |
46 | + subject: '[%s] %s' % [self.environment.name, task.target_notification_description], | |
47 | 47 | email_template: task.email_template, |
48 | - template_params: {:environment => task.requestor.environment, :task => task, :message => @message, :url => @url, :requestor => task.requestor} | |
48 | + template_params: {:environment => self.environment, :task => task, :message => @message, :url => @url, :requestor => task.requestor} | |
49 | 49 | ) |
50 | 50 | end |
51 | 51 | ... | ... |
test/unit/task_mailer_test.rb
... | ... | @@ -137,7 +137,7 @@ class TaskMailerTest < ActiveSupport::TestCase |
137 | 137 | |
138 | 138 | environment = Environment.default |
139 | 139 | environment.expects(:noreply_email).returns('sender@example.com') |
140 | - environment.expects(:default_hostname).returns('example.com') | |
140 | + environment.expects(:default_hostname).returns('example.com').at_least_once | |
141 | 141 | environment.expects(:name).returns('example').at_least_once |
142 | 142 | |
143 | 143 | task.expects(:requestor).returns(requestor).at_least_once |
... | ... | @@ -165,7 +165,7 @@ class TaskMailerTest < ActiveSupport::TestCase |
165 | 165 | |
166 | 166 | environment = Environment.default |
167 | 167 | environment.expects(:noreply_email).returns('sender@example.com') |
168 | - environment.expects(:default_hostname).returns('example.com') | |
168 | + environment.expects(:default_hostname).returns('example.com').at_least_once | |
169 | 169 | environment.expects(:name).returns('example').at_least_once |
170 | 170 | |
171 | 171 | task.expects(:requestor).returns(requestor).at_least_once | ... | ... |