From 6739bfc6651ecd9f7ec377b1232bb6d12ef478e4 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 21 Apr 2023 09:35:16 +0200 Subject: [PATCH 1/2] =?UTF-8?q?bug(instructeurs.annotations):=20ETQ=20inst?= =?UTF-8?q?ructeurs,=20lorsque=20je=20saisie=20une=20autre=20valeur=20dans?= =?UTF-8?q?=20un=20champ=20de=20type=20choix=20simple,=20celle=20ci=20n'es?= =?UTF-8?q?t=20pas=20sauvegard=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../instructeurs/dossiers_controller_spec.rb | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index 06f94d716..4b499faf4 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -762,28 +762,19 @@ describe Instructeurs::DossiersController, type: :controller do { type: :multiple_drop_down_list }, { type: :linked_drop_down_list }, { type: :datetime }, - { type: :repetition, children: [{}] } + { type: :repetition, children: [{}] }, + { type: :drop_down_list, options: [:a, :b, :other] } ], instructeurs: instructeurs) end let(:dossier) { create(:dossier, :en_construction, :with_populated_annotations, procedure: procedure) } let(:another_instructeur) { create(:instructeur) } let(:now) { Time.zone.parse('01/01/2100') } - let(:champ_multiple_drop_down_list) do - dossier.champs_private.first - end - - let(:champ_linked_drop_down_list) do - dossier.champs_private.second - end - - let(:champ_datetime) do - dossier.champs_private.third - end - - let(:champ_repetition) do - dossier.champs_private.fourth - end + let(:champ_multiple_drop_down_list) { dossier.champs_private.first } + let(:champ_linked_drop_down_list) { dossier.champs_private.second } + let(:champ_datetime) { dossier.champs_private.third } + let(:champ_repetition) { dossier.champs_private.fourth } + let(:champ_drop_down_list) { dossier.champs_private.fifth } before do expect(controller.current_instructeur).to receive(:mark_tab_as_seen).with(dossier, :annotations_privees) @@ -795,6 +786,7 @@ describe Instructeurs::DossiersController, type: :controller do champ_linked_drop_down_list.reload champ_datetime.reload champ_repetition.reload + champ_drop_down_list.reload end after do @@ -824,6 +816,11 @@ describe Instructeurs::DossiersController, type: :controller do '3': { id: champ_repetition.champs.first.id, value: 'text' + }, + '4': { + id: champ_drop_down_list.id, + value: '__other__', + value_other: 'other value' } } } @@ -836,6 +833,7 @@ describe Instructeurs::DossiersController, type: :controller do expect(champ_linked_drop_down_list.secondary_value).to eq('secondary') expect(champ_datetime.value).to eq('2019-12-21T13:17:00+01:00') expect(champ_repetition.champs.first.value).to eq('text') + expect(champ_drop_down_list.value).to eq('other value') expect(dossier.reload.last_champ_private_updated_at).to eq(now) expect(response).to have_http_status(200) } From b5e6c3d02a6fd894c0ef265bc045db1abd7ebafd Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 21 Apr 2023 09:37:27 +0200 Subject: [PATCH 2/2] =?UTF-8?q?correctif(instructeurs.annotations):=20pour?= =?UTF-8?q?=20un=20champ=20de=20type=20choix=20simple,=20l'ordre=20des=20p?= =?UTF-8?q?arametres=20value,=20value=5Fother=20doit=20etre=20respect?= =?UTF-8?q?=C3=A9=20sinon=20le=20'setters'=20`Champs::DropDownListChamp.va?= =?UTF-8?q?lue=3D`=20passe=20apr=C3=A8s=20le=20setter=20`Champs::DropDownL?= =?UTF-8?q?istChamp.value=5Fother=3D`,=20ce=20qui=20a=20pour=20effet=20de?= =?UTF-8?q?=20supprimer=20la=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/instructeurs/dossiers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index a5997544a..47c930eae 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -326,7 +326,7 @@ module Instructeurs def champs_private_params champs_params = params.require(:dossier).permit(champs_private_attributes: [ - :id, :primary_value, :secondary_value, :piece_justificative_file, :value_other, :external_id, :numero_allocataire, :code_postal, :code_departement, :value, value: [], + :id, :value, :primary_value, :secondary_value, :piece_justificative_file, :value_other, :external_id, :numero_allocataire, :code_postal, :code_departement, value: [], champs_attributes: [:id, :_destroy, :value, :primary_value, :secondary_value, :piece_justificative_file, :value_other, :external_id, :numero_allocataire, :code_postal, :code_departement, value: []] ]) champs_params[:champs_private_all_attributes] = champs_params.delete(:champs_private_attributes) || {}