hide decision displayed in messagerie with auto commentaire
This commit is contained in:
parent
b2e48b4dbe
commit
5bbc4cab50
5 changed files with 20 additions and 5 deletions
|
@ -3,9 +3,13 @@ class MailTemplatePresenterService
|
|||
include ActionView::Helpers::TextHelper
|
||||
|
||||
def self.create_commentaire_for_state(dossier, state)
|
||||
service = new(dossier, state)
|
||||
body = ["<p>[#{service.safe_subject}]</p>", service.safe_body].join('')
|
||||
CommentaireService.create!(CONTACT_EMAIL, dossier, body: body)
|
||||
if dossier.procedure.accuse_lecture? && Dossier::TERMINE.include?(state)
|
||||
CommentaireService.create!(CONTACT_EMAIL, dossier, body: I18n.t('layouts.mailers.accuse_lecture.commentaire_html', service: dossier.procedure.service.nom))
|
||||
else
|
||||
service = new(dossier, state)
|
||||
body = ["<p>[#{service.safe_subject}]</p>", service.safe_body].join('')
|
||||
CommentaireService.create!(CONTACT_EMAIL, dossier, body: body)
|
||||
end
|
||||
end
|
||||
|
||||
def safe_body
|
||||
|
|
|
@ -24,3 +24,9 @@ en:
|
|||
accepte: has been accepted on %{processed_at}.
|
||||
refuse: has been refused on %{processed_at}.
|
||||
sans_suite: has been closed without continuation on %{processed_at}.
|
||||
accuse_lecture:
|
||||
good_morning: Hello,
|
||||
first_part: We inform you that a decision on file no. %{dossier_id} of the procedure
|
||||
second_part: has been rendered.
|
||||
third_part: To find out its nature, please log in to your account
|
||||
commentaire_html: <p>Hello,</p><p>We inform you that a decision on your file has been rendered.</p>Sincerely,<br>%{service}
|
||||
|
|
|
@ -30,6 +30,7 @@ fr:
|
|||
first_part: Nous vous informons qu'une décision sur le dossier nº %{dossier_id} de la démarche
|
||||
second_part: a été rendue.
|
||||
third_part: Pour en connaitre la nature, veuillez vous connecter à votre compte
|
||||
commentaire_html: <p>Bonjour,</p><p>Nous vous informons qu'une décision sur votre dossier a été rendue.</p>Cordialement,<br>%{service}
|
||||
|
||||
commentaire_groupe_gestionnaire_footer:
|
||||
do_not_reply_html: Merci de ne pas répondre à cet email. Consultez votre message sur %{application_name} ou contactez votre expéditeur par <a href="mailto:%{sender_email}">mail</a>
|
||||
|
|
|
@ -398,6 +398,11 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
it { expect(subject.body).to include('header-top') }
|
||||
|
||||
it 'creates a commentaire' do
|
||||
expect { subject }.to change { Commentaire.count }.by(1)
|
||||
expect(dossier_accuse_lecture.commentaires.last.body).to eq("<p>Bonjour,</p><p>Nous vous informons qu'une décision sur votre dossier a été rendue.</p>Cordialement,<br>#{procedure_accuse_lecture.service.nom}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ RSpec.describe NotificationMailer, type: :mailer do
|
|||
end
|
||||
|
||||
describe 'send_accuse_lecture_notification' do
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure, :accuse_lecture)) }
|
||||
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: create(:procedure, :accuse_lecture)) }
|
||||
subject { described_class.send_accuse_lecture_notification(dossier) }
|
||||
|
||||
it { expect(subject.subject).to include("La décision a été rendue pour votre démarche #{dossier.procedure.libelle}") }
|
||||
|
|
Loading…
Reference in a new issue