fix(attachment): clone piece justificatives with multiple attachments
This commit is contained in:
parent
b609c3dae4
commit
7cbe6bbaa4
2 changed files with 4 additions and 2 deletions
|
@ -60,7 +60,9 @@ class PiecesJustificativesService
|
||||||
def self.clone_attachments(original, kopy)
|
def self.clone_attachments(original, kopy)
|
||||||
case original
|
case original
|
||||||
when Champs::PieceJustificativeChamp, Champs::TitreIdentiteChamp
|
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
|
when TypeDeChamp
|
||||||
clone_attachment(original.piece_justificative_template, kopy.piece_justificative_template)
|
clone_attachment(original.piece_justificative_template, kopy.piece_justificative_template)
|
||||||
when Procedure
|
when Procedure
|
||||||
|
|
|
@ -1783,7 +1783,7 @@ describe Dossier do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
let(:champ_piece_justificative) { create(:champ_piece_justificative, dossier_id: dossier.id) }
|
let(:champ_piece_justificative) { create(:champ_piece_justificative, dossier_id: dossier.id) }
|
||||||
before { dossier.champs_public << champ_piece_justificative }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue