fix(mail): limit generated subjects to 100 characters
This commit is contained in:
parent
4b0e6ea382
commit
5526cb5173
4 changed files with 45 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
|||
#
|
||||
class NotificationMailer < ApplicationMailer
|
||||
include ActionView::Helpers::SanitizeHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
before_action :set_dossier
|
||||
before_action :set_services_publics_plus, only: :send_notification
|
||||
|
@ -67,7 +68,7 @@ class NotificationMailer < ApplicationMailer
|
|||
mail_template = @dossier.procedure.mail_template_for(params[:state])
|
||||
|
||||
@email = @dossier.user_email_for(:notification)
|
||||
@subject = mail_template.subject_for_dossier(@dossier)
|
||||
@subject = truncate(mail_template.subject_for_dossier(@dossier), length: 100)
|
||||
@body = mail_template.body_for_dossier(@dossier)
|
||||
@actions = mail_template.actions_for_dossier(@dossier)
|
||||
@attachment = mail_template.attachment_for_dossier(@dossier)
|
||||
|
|
|
@ -395,6 +395,19 @@ en:
|
|||
zone: This procedure is run by
|
||||
champs:
|
||||
value: Value
|
||||
default_mail_attributes: &default_mail_attributes
|
||||
hints:
|
||||
subject: The generated subject will be truncated if it exceeds 100 characters.
|
||||
mails/closed_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/initiated_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/received_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/refused_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/without_continuation_mail:
|
||||
<< : *default_mail_attributes
|
||||
|
||||
errors:
|
||||
messages:
|
||||
|
|
|
@ -392,6 +392,19 @@ fr:
|
|||
zone: La démarche est mise en œuvre par
|
||||
champs:
|
||||
value: Valeur du champ
|
||||
default_mail_attributes: &default_mail_attributes
|
||||
hints:
|
||||
subject: "L’objet généré sera tronqué s’il dépasse 100 caractères."
|
||||
mails/closed_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/initiated_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/received_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/refused_mail:
|
||||
<< : *default_mail_attributes
|
||||
mails/without_continuation_mail:
|
||||
<< : *default_mail_attributes
|
||||
|
||||
errors:
|
||||
messages:
|
||||
|
|
|
@ -101,4 +101,21 @@ RSpec.describe NotificationMailer, type: :mailer do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'subject length' do
|
||||
let(:procedure) { create(:simple_procedure, libelle: "My super long title " + ("xo " * 100)) }
|
||||
let(:dossier) { create(:dossier, :en_instruction, :with_individual, :with_service, user: user, procedure: procedure) }
|
||||
let(:email_template) { create(:closed_mail, subject:, body: 'Your dossier was accepted. Thanks.') }
|
||||
|
||||
before do
|
||||
dossier.procedure.closed_mail = email_template
|
||||
end
|
||||
|
||||
subject(:mail) { described_class.send_accepte_notification(dossier) }
|
||||
|
||||
context "subject is too long" do
|
||||
let(:subject) { 'Un long libellé --libellé démarche--' }
|
||||
it { expect(mail.subject.length).to be <= 100 }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue