Commit 39394f370c5666834184b932ecdc38f844d1e061
1 parent
8ff8c9c1
Exists in
master
and in
29 other branches
ActionItem96: finishing implementation of tasks and mailing
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@623 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
35 additions
and
21 deletions
Show diff stats
app/models/environment.rb
app/models/task.rb
... | ... | @@ -53,18 +53,6 @@ class Task < ActiveRecord::Base |
53 | 53 | end |
54 | 54 | end |
55 | 55 | |
56 | - protected | |
57 | - | |
58 | - # This method must be overrided in subclasses, and its implementation must do | |
59 | - # the job the task is intended to. This method will be called when the finish | |
60 | - # method is called. | |
61 | - # | |
62 | - # To cancel the finish of the task, you can throw an exception in perform. | |
63 | - # | |
64 | - # The implementation on Task class just does nothing. | |
65 | - def perform | |
66 | - end | |
67 | - | |
68 | 56 | # The message that will be sent to the requestor of the task when its |
69 | 57 | # finished. |
70 | 58 | def finish_message |
... | ... | @@ -77,4 +65,24 @@ class Task < ActiveRecord::Base |
77 | 65 | _("The task was cancelled at %s") % (self.end_date.to_s) |
78 | 66 | end |
79 | 67 | |
68 | + # Returns the description of the task. | |
69 | + # | |
70 | + # This method +must+ be overriden in subclasses to return something | |
71 | + # meaningful for each kind of task | |
72 | + def description | |
73 | + _('Generic task') | |
74 | + end | |
75 | + | |
76 | + protected | |
77 | + | |
78 | + # This method must be overrided in subclasses, and its implementation must do | |
79 | + # the job the task is intended to. This method will be called when the finish | |
80 | + # method is called. | |
81 | + # | |
82 | + # To cancel the finish of the task, you can throw an exception in perform. | |
83 | + # | |
84 | + # The implementation on Task class just does nothing. | |
85 | + def perform | |
86 | + end | |
87 | + | |
80 | 88 | end | ... | ... |
app/models/task_mailer.rb
... | ... | @@ -3,7 +3,7 @@ class TaskMailer < ActionMailer::Base |
3 | 3 | def task_finished(task) |
4 | 4 | recipients task.requestor.email |
5 | 5 | from task.requestor.environment.contact_email |
6 | - subject task | |
6 | + subject task.description | |
7 | 7 | body :requestor => task.requestor.name, |
8 | 8 | :message => task.finish_message, |
9 | 9 | :environment => task.requestor.environment.name, |
... | ... | @@ -13,7 +13,7 @@ class TaskMailer < ActionMailer::Base |
13 | 13 | def task_cancelled(task) |
14 | 14 | recipients task.requestor.email |
15 | 15 | from task.requestor.environment.contact_email |
16 | - subject task | |
16 | + subject task.description | |
17 | 17 | body :requestor => task.requestor.name, |
18 | 18 | :message => task.cancel_message, |
19 | 19 | :environment => task.requestor.environment.name, | ... | ... |
app/views/task_mailer/task_cancelled.text.plain.rhtml
app/views/task_mailer/task_finished.text.plain.rhtml
db/migrate/017_create_tasks.rb
test/unit/environment_test.rb
... | ... | @@ -155,10 +155,13 @@ class EnvironmentTest < Test::Unit::TestCase |
155 | 155 | |
156 | 156 | should 'provide a default hostname' do |
157 | 157 | env = Environment.create!(:name => 'test environment') |
158 | - assert_nil env.default_hostname | |
159 | - | |
160 | 158 | env.domains << Domain.create(:name => 'example.com') |
161 | 159 | assert_equal 'example.com', env.default_hostname |
162 | 160 | end |
163 | 161 | |
162 | + should 'default to localhost.localdomain as hostname' do | |
163 | + env = Environment.create!(:name => 'test environment') | |
164 | + assert_equal 'localhost.localdomain', env.default_hostname | |
165 | + end | |
166 | + | |
164 | 167 | end | ... | ... |
test/unit/task_mailer_test.rb
... | ... | @@ -20,6 +20,7 @@ class TaskMailerTest < Test::Unit::TestCase |
20 | 20 | |
21 | 21 | task = mock() |
22 | 22 | task.expects(:finish_message).returns('the message') |
23 | + task.expects(:description).returns('the task') | |
23 | 24 | |
24 | 25 | requestor = mock() |
25 | 26 | requestor.expects(:email).returns('requestor@example.com') | ... | ... |