FIX: don't create an EmailLog when we can't send a digest

This commit is contained in:
Régis Hanol 2016-02-17 17:31:46 +01:00
parent 532fb7ea9d
commit 52a6682690
2 changed files with 11 additions and 1 deletions

View file

@ -23,6 +23,10 @@ module Email
def send
return if SiteSetting.disable_emails
return if ActionMailer::Base::NullMail === @message
return if ActionMailer::Base::NullMail === (@message.message rescue nil)
return skip(I18n.t('email_log.message_blank')) if @message.blank?
return skip(I18n.t('email_log.message_to_blank')) if @message.to.blank?

View file

@ -7,7 +7,13 @@ describe Email::Sender do
SiteSetting.expects(:disable_emails).returns(true)
Mail::Message.any_instance.expects(:deliver_now).never
message = Mail::Message.new(to: "hello@world.com" , body: "hello")
Email::Sender.new(message, :hello).send
expect(Email::Sender.new(message, :hello).send).to eq(nil)
end
it "doesn't deliver mail when the message is of type NullMail" do
Mail::Message.any_instance.expects(:deliver_now).never
message = ActionMailer::Base::NullMail.new
expect(Email::Sender.new(message, :hello).send).to eq(nil)
end
it "doesn't deliver mail when the message is nil" do