Merge pull request #8938 from mfo/US/annotation-privee-value-other

bug(instructeurs.annotations): ETQ instructeurs, lorsque je saisie une autre valeur dans un champ de type choix simple, celle ci n'est pas sauvegardé
This commit is contained in:
Colin Darie 2023-04-21 09:27:07 +00:00 committed by GitHub
commit a8ae706efd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 17 deletions

View file

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

View file

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