Commit 4d9ad46b99ac739104742d2aba9bfba34f8d3942
1 parent
990b96ad
Exists in
staging
and in
42 other branches
rails3: fix pending_task_notifier
Showing
3 changed files
with
22 additions
and
19 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +class PendingTaskNotifier < ActionMailer::Base | |
| 2 | + | |
| 3 | + def notification(person) | |
| 4 | + @person = person | |
| 5 | + @tasks = person.tasks.pending | |
| 6 | + @organizations_with_pending_tasks = person.organizations_with_pending_tasks | |
| 7 | + @environment = person.environment.name | |
| 8 | + @url = url_for(:host => person.environment.default_hostname, :controller => 'home') | |
| 9 | + @default_hostname = person.environment.default_hostname | |
| 10 | + @url_for_pending_tasks = url_for(:host => person.environment.default_hostname, :controller => 'tasks', :profile => person.identifier) | |
| 11 | + | |
| 12 | + mail( | |
| 13 | + to: person.email, | |
| 14 | + from: "#{person.environment.name} <#{person.environment.contact_email}>", | |
| 15 | + subject: _("[%s] Pending tasks") % person.environment.name | |
| 16 | + ) | |
| 17 | + end | |
| 18 | + | |
| 19 | +end | ... | ... |
app/models/pending_task_notifier.rb
| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | -class PendingTaskNotifier < ActionMailer::Base | |
| 2 | - | |
| 3 | - def notification(person) | |
| 4 | - recipients person.email | |
| 5 | - from "#{person.environment.name} <#{person.environment.contact_email}>" | |
| 6 | - subject _("[%s] Pending tasks") % person.environment.name | |
| 7 | - body :person => person, | |
| 8 | - :tasks => person.tasks.pending, | |
| 9 | - :organizations_with_pending_tasks => person.organizations_with_pending_tasks, | |
| 10 | - :environment => person.environment.name, | |
| 11 | - :url => url_for(:host => person.environment.default_hostname, :controller => 'home'), | |
| 12 | - :default_hostname => person.environment.default_hostname, | |
| 13 | - :url_for_pending_tasks => url_for(:host => person.environment.default_hostname, :controller => 'tasks', :profile => person.identifier) | |
| 14 | - end | |
| 15 | - | |
| 16 | -end |
test/unit/pending_task_notifier_test.rb
| ... | ... | @@ -14,7 +14,7 @@ class PendingTaskNotifierTest < ActiveSupport::TestCase |
| 14 | 14 | should 'be able to deliver notification' do |
| 15 | 15 | env = Environment.default |
| 16 | 16 | p = create_user('maelcum').person |
| 17 | - response = PendingTaskNotifier.deliver_notification(p) | |
| 17 | + response = PendingTaskNotifier.notification(p).deliver | |
| 18 | 18 | assert_equal "[#{env.name}] Pending tasks", response.subject |
| 19 | 19 | assert_equal p.email, response.to[0] |
| 20 | 20 | end |
| ... | ... | @@ -25,8 +25,8 @@ class PendingTaskNotifierTest < ActiveSupport::TestCase |
| 25 | 25 | c.add_admin(p) |
| 26 | 26 | c.tasks << Task.new(:requestor => p) |
| 27 | 27 | |
| 28 | - response = PendingTaskNotifier.deliver_notification(p) | |
| 29 | - assert_match /sent you a task/, response.body | |
| 28 | + response = PendingTaskNotifier.notification(p).deliver | |
| 29 | + assert_match /sent you a task/, response.body.to_s | |
| 30 | 30 | end |
| 31 | 31 | |
| 32 | 32 | private | ... | ... |