Migration PJ : corrige le rollback dans le cas où les dossiers sont cachés (#3971)
Migration des PJ : corrige le rollback dans le cas où les dossiers sont cachés
This commit is contained in:
commit
b98c6e1994
2 changed files with 17 additions and 1 deletions
|
@ -141,7 +141,7 @@ class PieceJustificativeToChampPieceJointeMigrationService
|
|||
# First destroy all the individual champs on dossiers
|
||||
type_champ.champ.each do |champ|
|
||||
begin
|
||||
destroy_champ_pj(champ.dossier.reload, champ)
|
||||
destroy_champ_pj(Dossier.unscope(where: :hidden_at).find(champ.dossier_id), champ)
|
||||
rescue => e
|
||||
rake_puts e
|
||||
rake_puts "Rolling back of champ #{champ.id} failed. Continuing to roll back…"
|
||||
|
|
|
@ -265,6 +265,22 @@ describe PieceJustificativeToChampPieceJointeMigrationService do
|
|||
.not_to change { ActiveStorage::Attachment.count }
|
||||
end
|
||||
|
||||
context 'when some dossiers to roll back are hidden' do
|
||||
before do
|
||||
dossier.update_column(:hidden_at, Time.zone.now)
|
||||
end
|
||||
|
||||
it 'does not create champs' do
|
||||
expect { try_convert(procedure) }
|
||||
.not_to change { dossier.champs.count }
|
||||
end
|
||||
|
||||
it 'does not change the hidden dossier timestamps' do
|
||||
try_convert(procedure)
|
||||
expect(dossier.updated_at).to eq(initial_dossier_timestamps[:updated_at])
|
||||
end
|
||||
end
|
||||
|
||||
context 'when receiving a Signal interruption (like Ctrl+C)' do
|
||||
let(:exception) { Interrupt }
|
||||
|
||||
|
|
Loading…
Reference in a new issue