Merge pull request #1661 from betagouv/frederic/fix_1563/add_lien_attestation_template
#1563 : add lien attestation template
This commit is contained in:
commit
f2ee041065
8 changed files with 68 additions and 7 deletions
|
@ -13,8 +13,13 @@ module MailTemplateConcern
|
|||
|
||||
module ClassMethods
|
||||
def default_for_procedure(procedure)
|
||||
body = ActionController::Base.new.render_to_string(template: self.const_get(:TEMPLATE_NAME))
|
||||
self.new(subject: self.const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
|
||||
template_name = default_template_name_for_procedure(procedure)
|
||||
body = ActionController::Base.new.render_to_string(template: template_name)
|
||||
new(subject: const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
|
||||
end
|
||||
|
||||
def default_template_name_for_procedure(procedure)
|
||||
const_get(:DEFAULT_TEMPLATE_NAME)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,9 +5,17 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "closed_mail"
|
||||
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
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "initiated_mail"
|
||||
TEMPLATE_NAME = "mails/initiated_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "mails/initiated_mail"
|
||||
DISPLAYED_NAME = 'Accusé de réception'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a bien été reçu'
|
||||
DOSSIER_STATE = 'en_construction'
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "received_mail"
|
||||
TEMPLATE_NAME = "mails/received_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "mails/received_mail"
|
||||
DISPLAYED_NAME = 'Accusé de passage en instruction'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- va être instruit'
|
||||
DOSSIER_STATE = 'en_instruction'
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "refused_mail"
|
||||
TEMPLATE_NAME = "mails/refused_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "mails/refused_mail"
|
||||
DISPLAYED_NAME = 'Accusé de rejet du dossier'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été refusé'
|
||||
DOSSIER_STATE = 'refuse'
|
||||
|
|
|
@ -5,7 +5,7 @@ module Mails
|
|||
belongs_to :procedure
|
||||
|
||||
SLUG = "without_continuation"
|
||||
TEMPLATE_NAME = "mails/without_continuation_mail"
|
||||
DEFAULT_TEMPLATE_NAME = "mails/without_continuation_mail"
|
||||
DISPLAYED_NAME = 'Accusé de classement sans suite'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été classé sans suite'
|
||||
DOSSIER_STATE = 'sans_suite'
|
||||
|
|
22
app/views/mails/closed_mail_with_attestation.html.haml
Normal file
22
app/views/mails/closed_mail_with_attestation.html.haml
Normal file
|
@ -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.
|
|
@ -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) }
|
||||
|
|
Loading…
Add table
Reference in a new issue