From 39b710fdde2d85d0c96a804cd4f0caa79a51c679 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 25 Mar 2019 11:08:41 +0100 Subject: [PATCH] Annotation: can use repetable --- .../new_gestionnaire/dossiers_controller.rb | 3 ++- .../dossiers_controller_spec.rb | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 1e06d4fac..d3fbd5917 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -164,7 +164,8 @@ module NewGestionnaire def champs_private_params params.require(:dossier).permit(champs_private_attributes: [ - :id, :primary_value, :secondary_value, :piece_justificative_file, :value, value: [] + :id, :primary_value, :secondary_value, :piece_justificative_file, :value, value: [], + champs_attributes: [:id, :_destroy, :value, :primary_value, :secondary_value, :piece_justificative_file, value: []] ]) end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 39c9137b5..3a2e412f1 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -363,8 +363,16 @@ describe NewGestionnaire::DossiersController, type: :controller do create(:type_de_champ_datetime, :private, libelle: 'libelle').champ.create end + let(:champ_repetition) do + tdc = create(:type_de_champ_repetition, :private, libelle: 'libelle') + tdc.types_de_champ << create(:type_de_champ_text, libelle: 'libelle') + champ = tdc.champ.create + champ.add_row + champ + end + let(:dossier) do - create(:dossier, :en_construction, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_linked_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, champ_repetition]) end before do @@ -389,6 +397,13 @@ describe NewGestionnaire::DossiersController, type: :controller do id: champ_linked_drop_down_list.id, primary_value: 'primary', secondary_value: 'secondary' + }, + '3': { + id: champ_repetition.id, + champs_attributes: { + id: champ_repetition.champs.first.id, + value: 'text' + } } } } @@ -397,12 +412,14 @@ describe NewGestionnaire::DossiersController, type: :controller do champ_multiple_drop_down_list.reload champ_linked_drop_down_list.reload champ_datetime.reload + champ_repetition.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(champ_repetition.champs.first.value).to eq('text') } it { expect(response).to redirect_to(annotations_privees_gestionnaire_dossier_path(dossier.procedure, dossier)) } end