models: require belong_to associations on procedure_presentation

Some tests are still failing
This commit is contained in:
Pierre de La Morinerie 2020-07-20 14:59:27 +00:00
parent 802d3804f5
commit ce53e219e0
2 changed files with 7 additions and 7 deletions

View file

@ -16,7 +16,7 @@ class ProcedurePresentation < ApplicationRecord
'self' => ['id', 'state'] 'self' => ['id', 'state']
} }
belongs_to :assign_to belongs_to :assign_to, optional: false
delegate :procedure, to: :assign_to delegate :procedure, to: :assign_to

View file

@ -12,8 +12,7 @@ describe ProcedurePresentation do
{ "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id } { "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id }
], ],
sort: { "table" => "user", "column" => "email", "order" => "asc" }, sort: { "table" => "user", "column" => "email", "order" => "asc" },
filters: filters filters: filters)
)
} }
let(:procedure_presentation_id) { procedure_presentation.id } let(:procedure_presentation_id) { procedure_presentation.id }
let(:filters) { { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] } } let(:filters) { { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] } }
@ -763,7 +762,7 @@ describe ProcedurePresentation do
context 'for type de champ' do context 'for type de champ' do
let(:table) { 'type_de_champ' } let(:table) { 'type_de_champ' }
let(:column) { procedure.types_de_champ.first.id } let(:column) { procedure.types_de_champ.first.id.to_s }
it 'preloads the champs relation' do it 'preloads the champs relation' do
# Ideally, we would only preload the champs for the matching column # Ideally, we would only preload the champs for the matching column
@ -780,7 +779,7 @@ describe ProcedurePresentation do
context 'for type de champ private' do context 'for type de champ private' do
let(:table) { 'type_de_champ_private' } let(:table) { 'type_de_champ_private' }
let(:column) { procedure.types_de_champ_private.first.id } let(:column) { procedure.types_de_champ_private.first.id.to_s }
it 'preloads the champs relation' do it 'preloads the champs relation' do
# Ideally, we would only preload the champs for the matching column # Ideally, we would only preload the champs for the matching column
@ -811,6 +810,7 @@ describe ProcedurePresentation do
end end
context 'for individual' do context 'for individual' do
let(:procedure) { create(:procedure, :for_individual, :with_type_de_champ, :with_type_de_champ_private) }
let(:table) { 'individual' } let(:table) { 'individual' }
let(:column) { 'nom' } let(:column) { 'nom' }
@ -857,9 +857,9 @@ describe ProcedurePresentation do
context 'for groupe_instructeur' do context 'for groupe_instructeur' do
let(:table) { 'groupe_instructeur' } let(:table) { 'groupe_instructeur' }
let(:column) { 'email' } let(:column) { 'label' }
it 'preloads the followers_instructeurs relation' do it 'preloads the groupe_instructeur relation' do
expect(displayed_dossier.association(:champs)).not_to be_loaded expect(displayed_dossier.association(:champs)).not_to be_loaded
expect(displayed_dossier.association(:champs_private)).not_to be_loaded expect(displayed_dossier.association(:champs_private)).not_to be_loaded
expect(displayed_dossier.association(:user)).not_to be_loaded expect(displayed_dossier.association(:user)).not_to be_loaded