Procedure Factory: use procedure.new_dossier

This commit is contained in:
simon lehericey 2019-08-26 15:31:44 +02:00
parent 6cbdba2665
commit d0bfb62fec
2 changed files with 13 additions and 3 deletions

View file

@ -155,7 +155,12 @@ class Procedure < ApplicationRecord
# Warning: dossier after_save build_default_champs must be removed
# to save a dossier created from this method
def new_dossier
Dossier.new(procedure: self, champs: build_champs, champs_private: build_champs_private)
Dossier.new(
procedure: self,
champs: build_champs,
champs_private: build_champs_private,
groupe_instructeur: defaut_groupe_instructeur
)
end
def build_champs

View file

@ -34,8 +34,13 @@ FactoryBot.define do
dossiers_count { 1 }
end
after(:build) do |procedure, evaluator|
procedure.dossiers << create_list(:dossier, evaluator.dossiers_count, procedure: procedure)
after(:create) do |procedure, evaluator|
user = create(:user)
evaluator.dossiers_count.times do
dossier = procedure.new_dossier
dossier.user = user
dossier.save!
end
end
end