diff --git a/app/models/mails/closed_mail.rb b/app/models/mails/closed_mail.rb index 8dae9d9ee..757593a3a 100644 --- a/app/models/mails/closed_mail.rb +++ b/app/models/mails/closed_mail.rb @@ -5,9 +5,17 @@ module Mails belongs_to :procedure SLUG = "closed_mail" - DEFAULT_TEMPLATE_NAME = "mails/closed_mail" DISPLAYED_NAME = "Accusé d'acceptation" DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été accepté' DOSSIER_STATE = 'accepte' + + def self.default_template_name_for_procedure(procedure) + attestation_template = procedure.attestation_template + if attestation_template.present? && attestation_template.activated? + "mails/closed_mail_with_attestation" + else + "mails/closed_mail" + end + end end end diff --git a/app/views/mails/closed_mail_with_attestation.html.haml b/app/views/mails/closed_mail_with_attestation.html.haml new file mode 100644 index 000000000..069fb6e77 --- /dev/null +++ b/app/views/mails/closed_mail_with_attestation.html.haml @@ -0,0 +1,22 @@ +Bonjour, +%br +%br +Votre dossier nº --numéro du dossier-- a été accepté le --date de décision--. +%br +%br +Vous pouvez télécharger votre attestation à l'adresse suivante : --lien attestation-- +%br +%br +A tout moment, vous pouvez consulter le contenu de vos dossiers et les éventuels commentaires de l'administration à cette adresse : --lien dossier-- +%br +%br +Bonne journée, +%br +%br +L'équipe demarches-simplifiees.fr (anciennement Téléprocédures Simplifiées) +%br +%br +— +%br +%br +Merci de ne pas répondre à cet email. Postez directement vos questions dans votre dossier sur la plateforme. diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 5dfb915b0..f513f0244 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -41,6 +41,32 @@ describe Procedure do end end + describe 'closed mail template body' do + let(:procedure) { create(:procedure) } + + subject { procedure.closed_mail_template.body } + + context 'for procedures without an attestation' do + it { is_expected.not_to include('lien attestation') } + end + + context 'for procedures with an attestation' do + before { create(:attestation_template, procedure: procedure, activated: activated) } + + context 'when the attestation is inactive' do + let(:activated) { false } + + it { is_expected.not_to include('lien attestation') } + end + + context 'when the attestation is inactive' do + let(:activated) { true } + + it { is_expected.to include('lien attestation') } + end + end + end + describe 'validation' do context 'libelle' do it { is_expected.not_to allow_value(nil).for(:libelle) }