diff --git a/app/models/dossier.rb b/app/models/dossier.rb index b1a152be2..51237c304 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -75,10 +75,10 @@ class Dossier < ApplicationRecord has_many :dossier_operation_logs, -> { order(:created_at) }, dependent: :nullify, inverse_of: :dossier - belongs_to :groupe_instructeur + belongs_to :groupe_instructeur, optional: false has_one :procedure, through: :groupe_instructeur belongs_to :revision, class_name: 'ProcedureRevision', optional: true - belongs_to :user + belongs_to :user, optional: false accepts_nested_attributes_for :champs accepts_nested_attributes_for :champs_private diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index c84a46d95..181c64f10 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -2,7 +2,7 @@ FactoryBot.define do factory :dossier do autorisation_donnees { true } state { Dossier.states.fetch(:brouillon) } - association :user, factory: [:user] + association :user transient do procedure { nil } diff --git a/spec/factories/etablissement.rb b/spec/factories/etablissement.rb index 68d7aa544..f0e5c24c8 100644 --- a/spec/factories/etablissement.rb +++ b/spec/factories/etablissement.rb @@ -25,9 +25,7 @@ FactoryBot.define do entreprise_date_creation { "1990-04-24" } trait :with_exercices do - after(:create) do |etablissement, _evaluator| - create(:exercice, etablissement: etablissement) - end + exercices { [association(:exercice)] } end trait :with_effectif_mensuel do diff --git a/spec/factories/exercice.rb b/spec/factories/exercice.rb index ee0bb7fa3..6a3438d7b 100644 --- a/spec/factories/exercice.rb +++ b/spec/factories/exercice.rb @@ -3,6 +3,6 @@ FactoryBot.define do ca { '12345678' } date_fin_exercice { "2014-12-30 23:00:00" } date_fin_exercice_timestamp { 1419980400 } - association :etablissement, factory: [:etablissement] + association :etablissement end end