Commit ec368658e08322cc21aff098ff460202b30b6afd
1 parent
f79e0f99
Exists in
master
and in
28 other branches
Small enhancement on if
(ActionItem2370)
Showing
2 changed files
with
10 additions
and
4 deletions
Show diff stats
app/models/task.rb
| @@ -64,8 +64,9 @@ class Task < ActiveRecord::Base | @@ -64,8 +64,9 @@ class Task < ActiveRecord::Base | ||
| 64 | 64 | ||
| 65 | begin | 65 | begin |
| 66 | target_msg = task.target_notification_message | 66 | target_msg = task.target_notification_message |
| 67 | - target_emails = task.target && task.target.notification_emails || [] | ||
| 68 | - TaskMailer.deliver_target_notification(task, target_msg) if target_msg && !target_emails.empty? | 67 | + if target_msg && task.target && !task.target.notification_emails.empty? |
| 68 | + TaskMailer.deliver_target_notification(task, target_msg) | ||
| 69 | + end | ||
| 69 | rescue NotImplementedError => ex | 70 | rescue NotImplementedError => ex |
| 70 | RAILS_DEFAULT_LOGGER.info ex.to_s | 71 | RAILS_DEFAULT_LOGGER.info ex.to_s |
| 71 | end | 72 | end |
| @@ -226,8 +227,9 @@ class Task < ActiveRecord::Base | @@ -226,8 +227,9 @@ class Task < ActiveRecord::Base | ||
| 226 | 227 | ||
| 227 | begin | 228 | begin |
| 228 | target_msg = target_notification_message | 229 | target_msg = target_notification_message |
| 229 | - target_emails = self.target && self.target.notification_emails || [] | ||
| 230 | - TaskMailer.deliver_target_notification(self, target_msg) if target_msg && !target_emails.empty? | 230 | + if target_msg && self.target && !self.target.notification_emails.empty? |
| 231 | + TaskMailer.deliver_target_notification(self, target_msg) | ||
| 232 | + end | ||
| 231 | rescue NotImplementedError => ex | 233 | rescue NotImplementedError => ex |
| 232 | RAILS_DEFAULT_LOGGER.info ex.to_s | 234 | RAILS_DEFAULT_LOGGER.info ex.to_s |
| 233 | end | 235 | end |
test/unit/organization_test.rb
| @@ -123,6 +123,10 @@ class OrganizationTest < ActiveSupport::TestCase | @@ -123,6 +123,10 @@ class OrganizationTest < ActiveSupport::TestCase | ||
| 123 | assert_equal ['admin1@email.com', 'admin2@email.com'], o.notification_emails | 123 | assert_equal ['admin1@email.com', 'admin2@email.com'], o.notification_emails |
| 124 | end | 124 | end |
| 125 | 125 | ||
| 126 | + should 'return empty array if contact_email is a blank string and it has no admin' do | ||
| 127 | + o = Organization.new(:contact_email => '', :environment => Environment.default) | ||
| 128 | + assert_equal [], o.notification_emails | ||
| 129 | + end | ||
| 126 | 130 | ||
| 127 | should 'list pending enterprise validations' do | 131 | should 'list pending enterprise validations' do |
| 128 | org = Organization.new | 132 | org = Organization.new |