Commit faeba294e907bb66a0b7774dabbbe6ce0eff81f5

Authored by Antonio Terceiro
1 parent bbfaed44

Environment: use contact_email for notifications

There is no point at all in send email to the noreply_email
app/models/environment.rb
@@ -804,7 +804,7 @@ class Environment < ActiveRecord::Base @@ -804,7 +804,7 @@ class Environment < ActiveRecord::Base
804 end 804 end
805 805
806 def notification_emails 806 def notification_emails
807 - [noreply_email.blank? ? nil : noreply_email].compact + admins.map(&:email) 807 + [contact_email].select(&:present?) + admins.map(&:email)
808 end 808 end
809 809
810 after_create :create_templates 810 after_create :create_templates
test/unit/environment_test.rb
@@ -195,6 +195,12 @@ class EnvironmentTest < ActiveSupport::TestCase @@ -195,6 +195,12 @@ class EnvironmentTest < ActiveSupport::TestCase
195 assert !env.errors[:contact_email.to_s].present? 195 assert !env.errors[:contact_email.to_s].present?
196 end 196 end
197 197
  198 + should 'notify contact email' do
  199 + env = Environment.new(:contact_email => 'foo@bar.com')
  200 + env.stubs(:admins).returns([])
  201 + assert_equal ['foo@bar.com'], env.notification_emails
  202 + end
  203 +
198 should 'provide a default hostname' do 204 should 'provide a default hostname' do
199 env = fast_create(Environment) 205 env = fast_create(Environment)
200 env.domains << create(Domain, :name => 'example.com', :is_default => true) 206 env.domains << create(Domain, :name => 'example.com', :is_default => true)