diff --git a/app/models/procedure.rb b/app/models/procedure.rb index b721afe24..120d96ef7 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -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 diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 6136d005b..b652d1cc0 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -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