From c6e2e6445ca03f9deb4afea8026009eadd521dc8 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 15 Apr 2024 10:37:47 +0200 Subject: [PATCH] add instructeur feedback on accuse de lecture agreement --- app/models/dossier.rb | 4 +++ app/views/shared/dossiers/_demande.html.haml | 9 ++++++ config/locales/en.yml | 3 ++ config/locales/fr.yml | 3 ++ .../dossiers/show.html.haml_spec.rb | 28 +++++++++++++++++++ .../users/dossiers/demande.html.haml_spec.rb | 1 + 6 files changed, 48 insertions(+) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 57ad9cd24..d2aafd943 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1184,6 +1184,10 @@ class Dossier < ApplicationRecord procedure.accuse_lecture? && termine? && accuse_lecture_agreement_at.blank? end + def termine_and_accuse_lecture? + procedure.accuse_lecture? && termine? + end + private def champs_by_public_id diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml index 2948c57d8..4a7e9d1d9 100644 --- a/app/views/shared/dossiers/_demande.html.haml +++ b/app/views/shared/dossiers/_demande.html.haml @@ -5,6 +5,15 @@ .fr-container.counter-start-header-section.dossier-show{ class: class_names("dossier-show-instructeur" => profile =="instructeur") } .fr-grid-row.fr-grid-row--center .fr-col-12.fr-col-xl-8 + - if profile == 'instructeur' && dossier.termine_and_accuse_lecture? + = render Dsfr::CalloutComponent.new(title: nil) do |c| + - c.with_html_body do + = t('views.shared.dossiers.demande.accuse_lecture') + - if dossier.accuse_lecture_agreement_at.present? + = t('views.shared.dossiers.demande.accuse_lecture_with_agreement', agreement: l(dossier.accuse_lecture_agreement_at, format: :long)) + - else + = t('views.shared.dossiers.demande.accuse_lecture_without_agreement') + %h2.fr-h6.fr-background-alt--grey.fr-mb-0 .flex-grow.fr-py-3v.fr-px-2w= t('views.shared.dossiers.demande.en_construction') diff --git a/config/locales/en.yml b/config/locales/en.yml index 7bab87554..d86e72fc9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -362,6 +362,9 @@ en: form: "Form" edit_siret: "Edit SIRET" edit_identity: "Edit identity data" + accuse_lecture: This procedure is subject to a reading receipt. + accuse_lecture_with_agreement: The user has read the decision taken on his file on %{agreement}. + accuse_lecture_without_agreement: The user has not yet learned of the decision on their file. gestionnaires: groupe_gestionnaires: delete: Delete diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 45ffc83bd..8da981b0e 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -365,6 +365,9 @@ fr: form: "Sections du formulaire" edit_siret: "Modifier le SIRET" edit_identity: "Modifier l’identité" + accuse_lecture: Cette démarche est soumise à un accusé de lecture. + accuse_lecture_with_agreement: L’usager a pris connaissance de la décision concernant son dossier le %{agreement}. + accuse_lecture_without_agreement: L’usager n’a pas encore pris connaissance de la décision concernant son dossier. gestionnaires: groupe_gestionnaires: delete: Supprimer diff --git a/spec/views/instructeur/dossiers/show.html.haml_spec.rb b/spec/views/instructeur/dossiers/show.html.haml_spec.rb index c9cd5eec9..ffbcb4e85 100644 --- a/spec/views/instructeur/dossiers/show.html.haml_spec.rb +++ b/spec/views/instructeur/dossiers/show.html.haml_spec.rb @@ -173,4 +173,32 @@ describe 'instructeurs/dossiers/show', type: :view do end end end + + describe 'accuse de lecture ' do + context 'dossier not termine' do + let(:dossier) { create(:dossier, :en_instruction, procedure: create(:procedure, :accuse_lecture)) } + + it 'does not display a text about accuse de lecture for instructeur' do + expect(subject).not_to have_text('Cette démarche est soumise à un accusé de lecture') + end + end + + context 'dossier termine with accuse de lecture not accepted by user' do + let(:dossier) { create(:dossier, :accepte, procedure: create(:procedure, :accuse_lecture)) } + + it 'displays a text about accuse de lecture for instructeur' do + expect(subject).to have_text('Cette démarche est soumise à un accusé de lecture') + expect(subject).to have_text('L’usager n’a pas encore pris connaissance de la décision concernant son dossier') + end + end + + context 'dossier termine with accuse de lecture accepted by user' do + let(:dossier) { create(:dossier, :accepte, accuse_lecture_agreement_at: Time.zone.now, procedure: create(:procedure, :accuse_lecture)) } + + it 'displays a text about accuse de lecture for instructeur' do + expect(subject).to have_text('Cette démarche est soumise à un accusé de lecture') + expect(subject).to have_text('L’usager a pris connaissance de la décision concernant son dossier le') + end + end + end end diff --git a/spec/views/users/dossiers/demande.html.haml_spec.rb b/spec/views/users/dossiers/demande.html.haml_spec.rb index 333db5574..e38fd440d 100644 --- a/spec/views/users/dossiers/demande.html.haml_spec.rb +++ b/spec/views/users/dossiers/demande.html.haml_spec.rb @@ -75,6 +75,7 @@ describe 'users/dossiers/demande', type: :view do it 'display information about accuse de lecture and not the motivation' do expect(rendered).to have_text('Cette démarche est soumise à un accusé de lecture.') expect(rendered).not_to have_text('Motivation') + expect(rendered).not_to have_text('L’usager n’a pas encore pris connaissance de la décision concernant son dossier') end end end