fix(expert_export): an expert export excludes annotation and avis

This commit is contained in:
simon lehericey 2023-01-18 11:42:25 +01:00 committed by Paul Chavard
parent c62d83a7f5
commit 84d08d4d24
3 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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
})

View file

@ -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