disable retry sending a mail with an invalid email adress
This commit is contained in:
parent
5a310b6c2b
commit
7f76ab6671
2 changed files with 24 additions and 0 deletions
|
@ -3,6 +3,10 @@ class ApplicationMailer < ActionMailer::Base
|
||||||
default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>"
|
default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>"
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
|
||||||
|
rescue_from Net::SMTPSyntaxError do |_error|
|
||||||
|
message.perform_deliveries = false
|
||||||
|
end
|
||||||
|
|
||||||
# Attach the procedure logo to the email (if any).
|
# Attach the procedure logo to the email (if any).
|
||||||
# Returns the attachment url.
|
# Returns the attachment url.
|
||||||
def attach_logo(procedure)
|
def attach_logo(procedure)
|
||||||
|
|
20
spec/mailers/application_mailer_spec.rb
Normal file
20
spec/mailers/application_mailer_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
RSpec.describe ApplicationMailer, type: :mailer do
|
||||||
|
describe 'dealing with invalid emails' do
|
||||||
|
let(:dossier) { create(:dossier, procedure: build(:simple_procedure)) }
|
||||||
|
subject { DossierMailer.notify_new_draft(dossier) }
|
||||||
|
|
||||||
|
describe 'invalid emails are not sent' do
|
||||||
|
before do
|
||||||
|
allow_any_instance_of(DossierMailer)
|
||||||
|
.to receive(:notify_new_draft)
|
||||||
|
.and_raise(Net::SMTPSyntaxError)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(subject.message).to be_an_instance_of(ActionMailer::Base::NullMail) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'valid emails are sent' do
|
||||||
|
it { expect(subject.message).not_to be_an_instance_of(ActionMailer::Base::NullMail) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue