diff --git a/app/lib/active_storage/downloadable_file.rb b/app/lib/active_storage/downloadable_file.rb index 5b3c3b4bd..4f84c7940 100644 --- a/app/lib/active_storage/downloadable_file.rb +++ b/app/lib/active_storage/downloadable_file.rb @@ -1,6 +1,6 @@ class ActiveStorage::DownloadableFile def self.create_list_from_dossiers(dossiers, for_expert = false) - PiecesJustificativesService.generate_dossier_export(dossiers) + + PiecesJustificativesService.generate_dossier_export(dossiers, include_infos_administration: !for_expert) + PiecesJustificativesService.liste_documents(dossiers, for_expert) end diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 0815e0c78..f7bb33861 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -83,7 +83,7 @@ class PiecesJustificativesService end end - def self.generate_dossier_export(dossiers) + def self.generate_dossier_export(dossiers, include_infos_administration: false) return [] if dossiers.empty? pdfs = [] @@ -97,7 +97,7 @@ class PiecesJustificativesService pdf = ApplicationController .render(template: 'dossiers/show', formats: [:pdf], assigns: { - include_infos_administration: true, + include_infos_administration:, dossier: dossier }) diff --git a/spec/controllers/experts/avis_controller_spec.rb b/spec/controllers/experts/avis_controller_spec.rb index c0cac0b54..239cacb33 100644 --- a/spec/controllers/experts/avis_controller_spec.rb +++ b/spec/controllers/experts/avis_controller_spec.rb @@ -96,8 +96,15 @@ describe Experts::AvisController, type: :controller do subject { get :telecharger_pjs, params: { id: avis.id, procedure_id: } } + before do + allow(PiecesJustificativesService).to receive(:generate_dossier_export).and_return([]).with([dossier], include_infos_administration: false) + end + context 'with a valid avis' do - it { is_expected.to have_http_status(:success) } + it do + is_expected.to have_http_status(:success) + expect(PiecesJustificativesService).to have_received(:generate_dossier_export) + end end context 'with a revoked avis' do