demarches-normaliennes/spec/factories/procedure_revision.rb

24 lines
852 B
Ruby
Raw Normal View History

2020-08-27 19:55:37 +02:00
FactoryBot.define do
factory :procedure_revision do
transient do
from_original { nil }
end
after(:build) do |revision, evaluator|
if evaluator.from_original
original = evaluator.from_original
revision.procedure = original.procedure
revision.attestation_template_id = original.attestation_template_id
revision.dossier_submitted_message_id = original.dossier_submitted_message_id
original.revision_types_de_champ_public.each do |r_tdc|
revision.revision_types_de_champ_public << build(:procedure_revision_type_de_champ, from_original: r_tdc)
end
original.revision_types_de_champ_private.each do |r_tdc|
revision.revision_types_de_champ_private << build(:procedure_revision_type_de_champ, from_original: r_tdc)
end
end
end
2020-08-27 19:55:37 +02:00
end
end