FIX: don't create an EmailLog when we can't send a digest
This commit is contained in:
parent
532fb7ea9d
commit
52a6682690
|
@ -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?
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue