Commit 95b5546d5fbf7e9d506fbfbf1bb844f61e918036
1 parent
523219ff
Exists in
master
and in
29 other branches
ActionItem36: changed Task to test a condition before sending e-mail. all tests
for Task pass. git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1466 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
15 additions
and
1 deletions
Show diff stats
app/models/task.rb
@@ -128,9 +128,23 @@ class Task < ActiveRecord::Base | @@ -128,9 +128,23 @@ class Task < ActiveRecord::Base | ||
128 | def perform | 128 | def perform |
129 | end | 129 | end |
130 | 130 | ||
131 | + # Tells wheter e-mail notifications must be sent or not. Returns | ||
132 | + # <tt>true</tt> by default (i.e. notification are sent), but can be overriden | ||
133 | + # in subclasses to disable notifications or even to send notifications based | ||
134 | + # on some conditions. | ||
135 | + def sends_email? | ||
136 | + true | ||
137 | + end | ||
138 | + | ||
131 | # sends notification e-mail about a task, if the task has a requestor. | 139 | # sends notification e-mail about a task, if the task has a requestor. |
140 | + # | ||
141 | + # If | ||
132 | def send_notification(action) | 142 | def send_notification(action) |
133 | - TaskMailer.send("deliver_task_#{action}", self) if self.requestor | 143 | + if sends_email? |
144 | + if self.requestor | ||
145 | + TaskMailer.send("deliver_task_#{action}", self) | ||
146 | + end | ||
147 | + end | ||
134 | end | 148 | end |
135 | 149 | ||
136 | class << self | 150 | class << self |