[fix #2241] GestionnaireDossierController: allow linked drop down value in update

This commit is contained in:
simon lehericey 2018-07-12 10:37:27 +02:00
parent e748b6883f
commit 0e8a1f1678
2 changed files with 14 additions and 2 deletions

View file

@ -187,7 +187,7 @@ module NewGestionnaire
def champs_private_params
params.require(:dossier).permit(champs_private_attributes: [
:id, :piece_justificative_file, :value, value: [],
:id, :primary_value, :secondary_value, :piece_justificative_file, :value, value: [],
etablissement_attributes: Champs::SiretChamp::ETABLISSEMENT_ATTRIBUTES
])
end

View file

@ -350,12 +350,16 @@ describe NewGestionnaire::DossiersController, type: :controller do
create(:type_de_champ_multiple_drop_down_list, :private, libelle: 'libelle').champ.create
end
let(:champ_linked_drop_down_list) do
create(:type_de_champ_linked_drop_down_list, :private, libelle: 'libelle').champ.create
end
let(:champ_datetime) do
create(:type_de_champ_datetime, :private, libelle: 'libelle').champ.create
end
let(:dossier) do
create(:dossier, :en_construction, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime])
create(:dossier, :en_construction, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_linked_drop_down_list, champ_datetime])
end
before do
@ -375,16 +379,24 @@ describe NewGestionnaire::DossiersController, type: :controller do
'value(3i)': 21,
'value(4i)': 13,
'value(5i)': 17
},
'2': {
id: champ_linked_drop_down_list.id,
primary_value: 'primary',
secondary_value: 'secondary'
}
}
}
}
champ_multiple_drop_down_list.reload
champ_linked_drop_down_list.reload
champ_datetime.reload
end
it { expect(champ_multiple_drop_down_list.value).to eq('["un", "deux"]') }
it { expect(champ_linked_drop_down_list.primary_value).to eq('primary') }
it { expect(champ_linked_drop_down_list.secondary_value).to eq('secondary') }
it { expect(champ_datetime.value).to eq('21/12/2019 13:17') }
it { expect(response).to redirect_to(annotations_privees_gestionnaire_dossier_path(dossier.procedure, dossier)) }
end