fix(dossier): add champs to dossiers in factories

This commit is contained in:
Paul Chavard 2024-12-10 10:19:55 +01:00
parent b3701a12b4
commit 7462a43886
No known key found for this signature in database

View file

@ -295,7 +295,7 @@ def dossier_factory_create_champ_or_repetition(type_de_champ, dossier)
types_de_champ = dossier.revision.children_of(type_de_champ)
2.times do
row_id = ULID.generate
type_de_champ.build_champ(dossier:, row_id:).save!
dossier.champs << type_de_champ.build_champ(row_id:)
types_de_champ.each do |type_de_champ|
dossier_factory_create_champ(type_de_champ, dossier, row_id:)
end
@ -313,6 +313,6 @@ def dossier_factory_create_champ(type_de_champ, dossier, row_id: nil)
elsif type_de_champ.multiple_drop_down_list?
type_de_champ.drop_down_options.first(2).to_json
end
attrs = { stable_id: type_de_champ.stable_id, private: type_de_champ.private?, row_id:, dossier:, value: }.compact
create(:"champ_do_not_use_#{type_de_champ.type_champ}", **attrs)
attrs = { stable_id: type_de_champ.stable_id, private: type_de_champ.private?, row_id:, value: }.compact
dossier.champs << build(:"champ_do_not_use_#{type_de_champ.type_champ}", **attrs)
end