factories: mark the parent procedure as for_individual

This ensures that we don't get an inconsistency, where a dossier is
`for_individual` while its procedure is not `for_individual`.
This commit is contained in:
Pierre de La Morinerie 2020-01-08 09:45:05 +00:00
parent 6a47458112
commit 00e5b736fb

View file

@ -37,9 +37,13 @@ FactoryBot.define do
end end
trait :for_individual do trait :for_individual do
after(:build) do |dossier, _evaluator| after(:build) do |dossier, evaluator|
# If the procedure was implicitely created by the factory,
# mark it automatically as for_individual.
if evaluator.procedure.nil?
dossier.procedure.update(for_individual: true)
end
dossier.individual = create(:individual) dossier.individual = create(:individual)
dossier.save
end end
end end