From 95b5546d5fbf7e9d506fbfbf1bb844f61e918036 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 21 Feb 2008 18:36:34 +0000 Subject: [PATCH] ActionItem36: changed Task to test a condition before sending e-mail. all tests for Task pass. --- app/models/task.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/models/task.rb b/app/models/task.rb index 7c59fe6..04ec99a 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -128,9 +128,23 @@ class Task < ActiveRecord::Base def perform end + # Tells wheter e-mail notifications must be sent or not. Returns + # true by default (i.e. notification are sent), but can be overriden + # in subclasses to disable notifications or even to send notifications based + # on some conditions. + def sends_email? + true + end + # sends notification e-mail about a task, if the task has a requestor. + # + # If def send_notification(action) - TaskMailer.send("deliver_task_#{action}", self) if self.requestor + if sends_email? + if self.requestor + TaskMailer.send("deliver_task_#{action}", self) + end + end end class << self -- libgit2 0.21.2