From a1f85f37844a62ff5067058d7b3e4451a168a959 Mon Sep 17 00:00:00 2001 From: Carlos Purificacao Date: Wed, 1 Jul 2015 19:46:18 -0300 Subject: [PATCH] Implemented the administrator task notification option - tests --- test/unit/task_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+), 0 deletions(-) diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index 00388e3..787b4a1 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -182,6 +182,32 @@ class TaskTest < ActiveSupport::TestCase task.save! end + should 'not send notification to target if notification is disabled in profile' do + task = Task.new + target = fast_create(Profile) + target.stubs(:notification_emails).returns(['adm@example.com']) + target.stubs(:administrator_mail_notification).returns(false) + task.target = target + task.stubs(:target_notification_message).returns('some non nil message to be sent to target') + TaskMailer.expects(:target_notification).never + task.save! + end + + should 'send notification to target if notification is enabled in profile' do + task = Task.new + target = fast_create(Profile) + target.stubs(:notification_emails).returns(['adm@example.com']) + target.stubs(:administrator_mail_notification).returns(true) + task.target = target + task.stubs(:target_notification_message).returns('some non nil message to be sent to target') + + + mailer = mock + mailer.expects(:deliver).once + TaskMailer.expects(:target_notification).returns(mailer).once + task.save! + end + should 'be able to list pending tasks' do Task.delete_all t1 = Task.create! -- libgit2 0.21.2