fix(mail): default subject fallback when subject template is empty

Closes #8448
This commit is contained in:
Colin Darie 2023-02-09 17:49:43 +01:00
parent 5526cb5173
commit aeb602a63d
2 changed files with 7 additions and 1 deletions

View file

@ -10,7 +10,7 @@ module MailTemplateConcern
end
def subject_for_dossier(dossier)
replace_tags(subject, dossier)
replace_tags(subject, dossier).presence || replace_tags(self.class::DEFAULT_SUBJECT, dossier)
end
def body_for_dossier(dossier)

View file

@ -117,5 +117,11 @@ RSpec.describe NotificationMailer, type: :mailer do
let(:subject) { 'Un long libellé --libellé démarche--' }
it { expect(mail.subject.length).to be <= 100 }
end
context "subject should fallback to default" do
let(:subject) { "" }
it { expect(mail.subject).to match(/^Votre dossier .+ a été accepté \(My super long title/) }
it { expect(mail.subject.length).to be <= 100 }
end
end
end