From 00e5b736fb4e9c3d2bf0e7952b759864829bd3f1 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 8 Jan 2020 09:45:05 +0000 Subject: [PATCH] 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`. --- spec/factories/dossier.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 73224330c..7847029f9 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -37,9 +37,13 @@ FactoryBot.define do end 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.save end end