clean(type_de_champ): remove magic factory

This commit is contained in:
Paul Chavard 2022-11-30 12:05:27 +01:00
parent 4eb6ec3e9d
commit c5901fbb95
8 changed files with 21 additions and 39 deletions

View file

@ -226,28 +226,6 @@ FactoryBot.define do
parent = revision.revision_types_de_champ.find { |rtdc| rtdc.type_de_champ == champ_repetition.type_de_champ }
types_de_champ = revision.revision_types_de_champ.filter { |rtdc| rtdc.parent == parent }.map(&:type_de_champ)
type_de_champ_text = types_de_champ.find { |tdc| tdc.libelle == 'Nom' }
if !type_de_champ_text
type_de_champ_text = build(:type_de_champ_text,
procedure: champ_repetition.type_de_champ.procedure,
position: 0,
private: champ_repetition.private?,
parent: parent,
libelle: 'Nom')
types_de_champ.push(type_de_champ_text)
end
type_de_champ_number = types_de_champ.find { |tdc| tdc.libelle == 'Age' }
if !type_de_champ_number
type_de_champ_number = build(:type_de_champ_number,
procedure: champ_repetition.type_de_champ.procedure,
position: 1,
private: champ_repetition.private?,
parent: parent,
libelle: 'Age')
types_de_champ.push(type_de_champ_number)
end
evaluator.rows.times do |row|
champ_repetition.champs << types_de_champ.map do |type_de_champ|
build(:"champ_#{type_de_champ.type_champ}", dossier: champ_repetition.dossier, row: row, type_de_champ: type_de_champ, parent: champ_repetition, private: champ_repetition.private?)