make the email notification more robust
This commit is contained in:
parent
2fc99bf90a
commit
6f2033a356
@ -94,7 +94,7 @@ class ContentInstance
|
||||
end
|
||||
|
||||
def send_notifications
|
||||
return unless self.content_type.api_enabled?
|
||||
return unless self.content_type.api_enabled? && !self.content_type.api_accounts.blank?
|
||||
|
||||
accounts = self.content_type.site.accounts.to_a
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
require 'mimetype_fu'
|
||||
require 'devise'
|
||||
|
||||
require 'locomotive/version'
|
||||
require 'locomotive/core_ext'
|
||||
@ -52,6 +53,9 @@ module Locomotive
|
||||
|
||||
# Heroku support
|
||||
self.enable_heroku if self.heroku?
|
||||
|
||||
# Devise
|
||||
Devise.mailer_sender = self.config.mailer_sender
|
||||
end
|
||||
|
||||
def self.logger(message)
|
||||
|
@ -80,6 +80,12 @@ describe ContentInstance do
|
||||
@content.save
|
||||
end
|
||||
|
||||
it 'does not send email notifications if no api accounts' do
|
||||
@content_type.api_accounts = nil
|
||||
Admin::Notifications.expects(:new_content_instance).never
|
||||
@content.save
|
||||
end
|
||||
|
||||
it 'sends email notifications when a new instance is created' do
|
||||
Admin::Notifications.expects(:new_content_instance).with(@account_1, @content).returns(mock('mailer', :deliver => true))
|
||||
Admin::Notifications.expects(:new_content_instance).with(@account_2, @content).returns(mock('mailer', :deliver => true))
|
||||
|
Loading…
Reference in New Issue
Block a user