bug(merge_fork): un dossier etant sur une revision passee avec une repetition qui a ete supprime ne peut merge_fork

This commit is contained in:
Martin 2023-06-30 14:25:23 +02:00
parent 30f6aaed34
commit 5c9101d15f
2 changed files with 18 additions and 4 deletions

View file

@ -172,9 +172,6 @@ module DossierCloneConcern
champs_to_remove += diff[:removed] champs_to_remove += diff[:removed]
champs_to_remove champs_to_remove
.filter { !_1.child? || !champs_to_remove.include?(_1.parent) } .filter { !_1.child? || !champs_to_remove.include?(_1.parent) }
.each do |champ| .each(&:destroy!)
champ.rows.flatten.each(&:destroy!) if champ.repetition?
champ.destroy!
end
end end
end end

View file

@ -341,5 +341,22 @@ RSpec.describe DossierCloneConcern do
expect(Dossier.exists?(forked_dossier.id)).to be_falsey expect(Dossier.exists?(forked_dossier.id)).to be_falsey
end end
end end
context 'with old revision having repetition' do
let(:added_champ) { nil }
let(:removed_champ) { dossier.champs.find(&:repetition?) }
let(:updated_champ) { nil }
before do
dossier.champs.each do |champ|
champ.update(value: 'old value')
end
procedure.draft_revision.remove_type_de_champ(removed_champ.stable_id)
procedure.publish_revision!
end
it 'works' do
expect { subject }.not_to raise_error(ActiveRecord::InvalidForeignKey)
end
end
end end
end end