Commit 05765444f2e835551ba4971382e8f77ea6252122

Authored by Victor Costa
1 parent 9c61af94

Fix mail sending at send_notification method

app/controllers/public/account_controller.rb
@@ -193,7 +193,7 @@ class AccountController < ApplicationController @@ -193,7 +193,7 @@ class AccountController < ApplicationController
193 else 193 else
194 @change_password.errors[:base] << _('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]] 194 @change_password.errors[:base] << _('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]]
195 end 195 end
196 - rescue ActiveRecord::RecordInvald 196 + rescue ActiveRecord::RecordInvalid
197 @change_password.errors[:base] << _('Could not perform password recovery for the user.') 197 @change_password.errors[:base] << _('Could not perform password recovery for the user.')
198 end 198 end
199 end 199 end
app/models/task.rb
@@ -286,7 +286,7 @@ class Task &lt; ActiveRecord::Base @@ -286,7 +286,7 @@ class Task &lt; ActiveRecord::Base
286 def send_notification(action) 286 def send_notification(action)
287 if sends_email? 287 if sends_email?
288 if self.requestor 288 if self.requestor
289 - TaskMailer.generic_message("task_#{action}", self) 289 + TaskMailer.generic_message("task_#{action}", self).deliver
290 end 290 end
291 end 291 end
292 end 292 end
app/views/task_mailer/generic_message.text.erb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= @message %>
test/unit/task_test.rb
@@ -29,7 +29,9 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -29,7 +29,9 @@ class TaskTest &lt; ActiveSupport::TestCase
29 end 29 end
30 30
31 def test_should_call_perform_in_finish 31 def test_should_call_perform_in_finish
32 - TaskMailer.expects(:generic_message).with('task_finished', anything) 32 + mail = mock
  33 + mail.expects(:deliver)
  34 + TaskMailer.expects(:generic_message).with('task_finished', anything).returns(mail)
33 t = Task.create 35 t = Task.create
34 t.requestor = sample_user 36 t.requestor = sample_user
35 t.expects(:perform) 37 t.expects(:perform)
@@ -38,7 +40,9 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -38,7 +40,9 @@ class TaskTest &lt; ActiveSupport::TestCase
38 end 40 end
39 41
40 def test_should_have_cancelled_status_after_cancel 42 def test_should_have_cancelled_status_after_cancel
41 - TaskMailer.expects(:generic_message).with('task_cancelled', anything) 43 + mail = mock
  44 + mail.expects(:deliver)
  45 + TaskMailer.expects(:generic_message).with('task_cancelled', anything).returns(mail)
42 t = Task.create 46 t = Task.create
43 t.requestor = sample_user 47 t.requestor = sample_user
44 t.cancel 48 t.cancel
@@ -54,7 +58,9 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -54,7 +58,9 @@ class TaskTest &lt; ActiveSupport::TestCase
54 t = Task.create 58 t = Task.create
55 t.requestor = sample_user 59 t.requestor = sample_user
56 60
57 - TaskMailer.expects(:generic_message).with('task_finished', t) 61 + mail = mock
  62 + mail.expects(:deliver)
  63 + TaskMailer.expects(:generic_message).with('task_finished', t).returns(mail)
58 64
59 t.finish 65 t.finish
60 end 66 end
@@ -63,7 +69,9 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -63,7 +69,9 @@ class TaskTest &lt; ActiveSupport::TestCase
63 t = Task.create 69 t = Task.create
64 t.requestor = sample_user 70 t.requestor = sample_user
65 71
66 - TaskMailer.expects(:generic_message).with('task_cancelled', t) 72 + mail = mock
  73 + mail.expects(:deliver)
  74 + TaskMailer.expects(:generic_message).with('task_cancelled', t).returns(mail)
67 75
68 t.cancel 76 t.cancel
69 end 77 end
@@ -93,7 +101,9 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -93,7 +101,9 @@ class TaskTest &lt; ActiveSupport::TestCase
93 task = Task.new 101 task = Task.new
94 task.requestor = sample_user 102 task.requestor = sample_user
95 103
96 - TaskMailer.expects(:generic_message).with('task_created', task) 104 + mail = mock
  105 + mail.expects(:deliver)
  106 + TaskMailer.expects(:generic_message).with('task_created', task).returns(mail)
97 task.save! 107 task.save!
98 end 108 end
99 109
@@ -281,7 +291,9 @@ class TaskTest &lt; ActiveSupport::TestCase @@ -281,7 +291,9 @@ class TaskTest &lt; ActiveSupport::TestCase
281 task.requestor = sample_user 291 task.requestor = sample_user
282 task.save! 292 task.save!
283 293
284 - TaskMailer.expects(:generic_message).with('task_activated', task) 294 + mail = mock
  295 + mail.expects(:deliver)
  296 + TaskMailer.expects(:generic_message).with('task_activated', task).returns(mail)
285 task.activate 297 task.activate
286 end 298 end
287 299