From 34b0578d70b55deeeb82c12b87561f632490d247 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 4 Apr 2022 23:00:54 +0200 Subject: [PATCH] pj_and_path only take dossier id --- app/lib/active_storage/downloadable_file.rb | 6 +++--- app/services/pieces_justificatives_service.rb | 2 +- spec/services/procedure_archive_service_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/lib/active_storage/downloadable_file.rb b/app/lib/active_storage/downloadable_file.rb index 93842d5cb..0cbacfe95 100644 --- a/app/lib/active_storage/downloadable_file.rb +++ b/app/lib/active_storage/downloadable_file.rb @@ -1,16 +1,16 @@ class ActiveStorage::DownloadableFile def self.create_list_from_dossiers(dossiers, for_expert = false) dossiers - .map { |d| pj_and_path(d, PiecesJustificativesService.generate_dossier_export(d)) } + + .map { |d| pj_and_path(d.id, PiecesJustificativesService.generate_dossier_export(d)) } + PiecesJustificativesService.liste_documents(dossiers, for_expert) end private - def self.pj_and_path(dossier, pj) + def self.pj_and_path(dossier_id, pj) [ pj, - "dossier-#{dossier.id}/#{self.timestamped_filename(pj)}" + "dossier-#{dossier_id}/#{self.timestamped_filename(pj)}" ] end diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index f836d9989..749c2037a 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -5,7 +5,7 @@ class PiecesJustificativesService pjs_for_commentaires(dossier) + pjs_for_dossier(dossier, for_expert) - pjs.map { |piece_justificative| ActiveStorage::DownloadableFile.pj_and_path(dossier, piece_justificative) } + pjs.map { |piece_justificative| ActiveStorage::DownloadableFile.pj_and_path(dossier.id, piece_justificative) } end end diff --git a/spec/services/procedure_archive_service_spec.rb b/spec/services/procedure_archive_service_spec.rb index e0ea87ccc..72c99a62a 100644 --- a/spec/services/procedure_archive_service_spec.rb +++ b/spec/services/procedure_archive_service_spec.rb @@ -106,7 +106,7 @@ describe ProcedureArchiveService do ) end - let(:documents) { [pj, bad_pj].map { |p| ActiveStorage::DownloadableFile.pj_and_path(dossier, p) } } + let(:documents) { [pj, bad_pj].map { |p| ActiveStorage::DownloadableFile.pj_and_path(dossier.id, p) } } before do allow(PiecesJustificativesService).to receive(:liste_documents).and_return(documents) end