mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
FIX: don't create an EmailLog when we can't send a digest
This commit is contained in:
parent
532fb7ea9d
commit
52a6682690
2 changed files with 11 additions and 1 deletions
|
@ -23,6 +23,10 @@ module Email
|
||||||
|
|
||||||
def send
|
def send
|
||||||
return if SiteSetting.disable_emails
|
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_blank')) if @message.blank?
|
||||||
return skip(I18n.t('email_log.message_to_blank')) if @message.to.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)
|
SiteSetting.expects(:disable_emails).returns(true)
|
||||||
Mail::Message.any_instance.expects(:deliver_now).never
|
Mail::Message.any_instance.expects(:deliver_now).never
|
||||||
message = Mail::Message.new(to: "hello@world.com" , body: "hello")
|
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
|
end
|
||||||
|
|
||||||
it "doesn't deliver mail when the message is nil" do
|
it "doesn't deliver mail when the message is nil" do
|
||||||
|
|
Loading…
Reference in a new issue