diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index b6522f620..eb1097b4b 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -60,7 +60,9 @@ class PiecesJustificativesService def self.clone_attachments(original, kopy) case original when Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp - clone_attachment(original.piece_justificative_file, kopy.piece_justificative_file) + original.piece_justificative_file.attachments.each do |attachment| + kopy.piece_justificative_file.attach(attachment.blob) + end when TypeDeChamp clone_attachment(original.piece_justificative_template, kopy.piece_justificative_template) when Procedure diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index e24976709..1e1cff1a5 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -1783,7 +1783,7 @@ describe Dossier do let(:dossier) { create(:dossier) } let(:champ_piece_justificative) { create(:champ_piece_justificative, dossier_id: dossier.id) } before { dossier.champs_public << champ_piece_justificative } - it { expect(Champs::PieceJustificativeChamp.where(dossier: new_dossier).first.piece_justificative_file.blob).to eq(champ_piece_justificative.piece_justificative_file.blob) } + it { expect(Champs::PieceJustificativeChamp.where(dossier: new_dossier).first.piece_justificative_file.first.blob).to eq(champ_piece_justificative.piece_justificative_file.first.blob) } end end