Merge pull request #7164 from betagouv/allow_cloning_procedure_with_missing_pj

une procédure avec des pj manquantes peut être clonée
This commit is contained in:
LeSim 2022-04-14 13:52:07 +02:00 committed by GitHub
commit a50efc7f83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -454,7 +454,10 @@ class Procedure < ApplicationRecord
}
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
procedure = self.deep_clone(include: include_list) do |original, kopy|
PiecesJustificativesService.clone_attachments(original, kopy)
begin
PiecesJustificativesService.clone_attachments(original, kopy)
rescue ActiveStorage::FileNotFoundError
end
end
procedure.path = SecureRandom.uuid
procedure.aasm_state = :brouillon

View file

@ -647,6 +647,16 @@ describe Procedure do
expect(subject.canonical_procedure).to be_nil
end
end
context 'with an pj not found' do
let(:procedure) { create(:procedure) }
before do
expect(PiecesJustificativesService).to receive(:clone_attachments).at_least(:once).and_raise(ActiveStorage::FileNotFoundError)
end
it { expect { procedure.clone(administrateur, false) }.not_to raise_error }
end
end
describe '#publish!' do