From f1525a798fcae9dc7189293965973f67517f5fff Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 29 Nov 2021 15:00:50 +0100 Subject: [PATCH 1/3] Avis : display introduction file to experts --- app/views/instructeurs/shared/avis/_list.html.haml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/instructeurs/shared/avis/_list.html.haml b/app/views/instructeurs/shared/avis/_list.html.haml index f40d05d18..fb1f6b032 100644 --- a/app/views/instructeurs/shared/avis/_list.html.haml +++ b/app/views/instructeurs/shared/avis/_list.html.haml @@ -40,6 +40,11 @@ - if avis.revokable_by?(current_instructeur) | = link_to(t('revoke', scope: 'helpers.label'), revoquer_instructeur_avis_path(avis.procedure, avis), data: { confirm: t('revoke', scope: 'helpers.confirmation', email: avis.expert.email) }, method: :patch) + - if avis.introduction_file.attached? + = render partial: 'shared/attachment/show', locals: { attachment: avis.introduction_file.attachment } + .answer-body.mb-3 + %p #{t('views.instructeurs.avis.introduction_file_explaination')} #{avis.claimant.email} + - if avis.piece_justificative_file.attached? = render partial: 'shared/attachment/show', locals: { attachment: avis.piece_justificative_file.attachment } .answer-body From 9d9ac546892c8fb8ceaf75cdfe3a99e9638e9228 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Mon, 29 Nov 2021 16:27:54 +0100 Subject: [PATCH 2/3] tests --- .../instructeur/shared/avis/list.html.haml_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/views/instructeur/shared/avis/list.html.haml_spec.rb b/spec/views/instructeur/shared/avis/list.html.haml_spec.rb index 4ebc6bb6f..30dbd6cc0 100644 --- a/spec/views/instructeur/shared/avis/list.html.haml_spec.rb +++ b/spec/views/instructeur/shared/avis/list.html.haml_spec.rb @@ -4,10 +4,12 @@ describe 'instructeurs/shared/avis/_list.html.haml', type: :view do subject { render 'instructeurs/shared/avis/list.html.haml', avis: avis, avis_seen_at: seen_at, current_instructeur: instructeur } let(:instructeur) { create(:instructeur) } + let(:instructeur2) { create(:instructeur) } + let(:introduction_file) { fixture_file_upload('spec/fixtures/files/piece_justificative_0.pdf', 'application/pdf') } let(:expert) { create(:expert) } let!(:dossier) { create(:dossier) } let(:experts_procedure) { create(:experts_procedure, expert: expert, procedure: dossier.procedure) } - let(:avis) { [create(:avis, claimant: instructeur, experts_procedure: experts_procedure)] } + let(:avis) { [create(:avis, claimant: instructeur, experts_procedure: experts_procedure, introduction_file: introduction_file)] } let(:seen_at) { avis.first.created_at + 1.hour } it { is_expected.to have_text(avis.first.introduction) } @@ -16,6 +18,7 @@ describe 'instructeurs/shared/avis/_list.html.haml', type: :view do context 'with a seen_at before avis created_at' do let(:seen_at) { avis.first.created_at - 1.hour } + it { is_expected.to have_text("Fichier joint à la demande d’avis") } it { is_expected.to have_css(".highlighted") } end @@ -26,4 +29,12 @@ describe 'instructeurs/shared/avis/_list.html.haml', type: :view do expect(subject).to include(simple_format(avis.first.answer)) end end + + context 'with another instructeur' do + let(:avis) { [create(:avis, :with_answer, claimant: instructeur2, experts_procedure: experts_procedure, introduction_file: introduction_file)] } + + it 'shows the files attached to the avis request' do + expect(subject).to have_text("Fichier joint à la demande d’avis") + end + end end From ffcae81249ac6ed04edca6d7cb878b1ada266e4b Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Tue, 30 Nov 2021 12:31:32 +0100 Subject: [PATCH 3/3] change locales --- config/locales/en.yml | 2 ++ config/locales/fr.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 875000695..37d74c65f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -135,6 +135,8 @@ en: instructeurs: dossiers: deleted_by_user: "File deleted by user" + avis: + introduction_file_explaination: "File attached to the request for advice" users: dossiers: autosave: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 74505b67d..a777d405a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -131,6 +131,8 @@ fr: instructeurs: dossiers: deleted_by_user: "Dossier supprimé par l'usager" + avis: + introduction_file_explaination: "Fichier joint à la demande d’avis" users: dossiers: autosave: