models: require belong_to associations on dossier

This commit is contained in:
Pierre de La Morinerie 2020-07-20 14:38:59 +00:00
parent 01248022bf
commit 51d392a1dc
4 changed files with 5 additions and 7 deletions

View file

@ -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

View file

@ -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 }

View file

@ -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

View file

@ -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