diff --git a/app/models/dossier_preloader.rb b/app/models/dossier_preloader.rb index 1f416da9b..9e49256f7 100644 --- a/app/models/dossier_preloader.rb +++ b/app/models/dossier_preloader.rb @@ -32,7 +32,7 @@ class DossierPreloader def load_dossiers(dossiers) all_champs = Champ - .includes(:type_de_champ, piece_justificative_file_attachment: :blob) + .includes(type_de_champ: { piece_justificative_template_attachment: :blob }, piece_justificative_file_attachment: :blob) .where(dossier_id: dossiers) .to_a diff --git a/spec/models/dossier_preloader_spec.rb b/spec/models/dossier_preloader_spec.rb index c25a58fb2..70cd8db30 100644 --- a/spec/models/dossier_preloader_spec.rb +++ b/spec/models/dossier_preloader_spec.rb @@ -27,6 +27,7 @@ describe DossierPreloader do expect(first_child.type).to eq('Champs::TextChamp') expect(repetition.id).not_to eq(first_child.id) expect(subject.champs.first.dossier).to eq(subject) + expect(subject.champs.first.type_de_champ.piece_justificative_template.attached?).to eq(false) expect(first_child.parent).to eq(repetition) end