Commit a1f85f37844a62ff5067058d7b3e4451a168a959
1 parent
7370a285
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Implemented the administrator task notification option - tests
Showing
1 changed file
with
26 additions
and
0 deletions
Show diff stats
test/unit/task_test.rb
| ... | ... | @@ -182,6 +182,32 @@ class TaskTest < ActiveSupport::TestCase |
| 182 | 182 | task.save! |
| 183 | 183 | end |
| 184 | 184 | |
| 185 | + should 'not send notification to target if notification is disabled in profile' do | |
| 186 | + task = Task.new | |
| 187 | + target = fast_create(Profile) | |
| 188 | + target.stubs(:notification_emails).returns(['adm@example.com']) | |
| 189 | + target.stubs(:administrator_mail_notification).returns(false) | |
| 190 | + task.target = target | |
| 191 | + task.stubs(:target_notification_message).returns('some non nil message to be sent to target') | |
| 192 | + TaskMailer.expects(:target_notification).never | |
| 193 | + task.save! | |
| 194 | + end | |
| 195 | + | |
| 196 | + should 'send notification to target if notification is enabled in profile' do | |
| 197 | + task = Task.new | |
| 198 | + target = fast_create(Profile) | |
| 199 | + target.stubs(:notification_emails).returns(['adm@example.com']) | |
| 200 | + target.stubs(:administrator_mail_notification).returns(true) | |
| 201 | + task.target = target | |
| 202 | + task.stubs(:target_notification_message).returns('some non nil message to be sent to target') | |
| 203 | + | |
| 204 | + | |
| 205 | + mailer = mock | |
| 206 | + mailer.expects(:deliver).once | |
| 207 | + TaskMailer.expects(:target_notification).returns(mailer).once | |
| 208 | + task.save! | |
| 209 | + end | |
| 210 | + | |
| 185 | 211 | should 'be able to list pending tasks' do |
| 186 | 212 | Task.delete_all |
| 187 | 213 | t1 = Task.create! | ... | ... |