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:
commit
a8ae706efd
2 changed files with 15 additions and 17 deletions
|
@ -326,7 +326,7 @@ module Instructeurs
|
||||||
|
|
||||||
def champs_private_params
|
def champs_private_params
|
||||||
champs_params = params.require(:dossier).permit(champs_private_attributes: [
|
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_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) || {}
|
champs_params[:champs_private_all_attributes] = champs_params.delete(:champs_private_attributes) || {}
|
||||||
|
|
|
@ -762,28 +762,19 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
{ type: :multiple_drop_down_list },
|
{ type: :multiple_drop_down_list },
|
||||||
{ type: :linked_drop_down_list },
|
{ type: :linked_drop_down_list },
|
||||||
{ type: :datetime },
|
{ type: :datetime },
|
||||||
{ type: :repetition, children: [{}] }
|
{ type: :repetition, children: [{}] },
|
||||||
|
{ type: :drop_down_list, options: [:a, :b, :other] }
|
||||||
], instructeurs: instructeurs)
|
], instructeurs: instructeurs)
|
||||||
end
|
end
|
||||||
let(:dossier) { create(:dossier, :en_construction, :with_populated_annotations, procedure: procedure) }
|
let(:dossier) { create(:dossier, :en_construction, :with_populated_annotations, procedure: procedure) }
|
||||||
let(:another_instructeur) { create(:instructeur) }
|
let(:another_instructeur) { create(:instructeur) }
|
||||||
let(:now) { Time.zone.parse('01/01/2100') }
|
let(:now) { Time.zone.parse('01/01/2100') }
|
||||||
|
|
||||||
let(:champ_multiple_drop_down_list) do
|
let(:champ_multiple_drop_down_list) { dossier.champs_private.first }
|
||||||
dossier.champs_private.first
|
let(:champ_linked_drop_down_list) { dossier.champs_private.second }
|
||||||
end
|
let(:champ_datetime) { dossier.champs_private.third }
|
||||||
|
let(:champ_repetition) { dossier.champs_private.fourth }
|
||||||
let(:champ_linked_drop_down_list) do
|
let(:champ_drop_down_list) { dossier.champs_private.fifth }
|
||||||
dossier.champs_private.second
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:champ_datetime) do
|
|
||||||
dossier.champs_private.third
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:champ_repetition) do
|
|
||||||
dossier.champs_private.fourth
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
expect(controller.current_instructeur).to receive(:mark_tab_as_seen).with(dossier, :annotations_privees)
|
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_linked_drop_down_list.reload
|
||||||
champ_datetime.reload
|
champ_datetime.reload
|
||||||
champ_repetition.reload
|
champ_repetition.reload
|
||||||
|
champ_drop_down_list.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -824,6 +816,11 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
'3': {
|
'3': {
|
||||||
id: champ_repetition.champs.first.id,
|
id: champ_repetition.champs.first.id,
|
||||||
value: 'text'
|
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_linked_drop_down_list.secondary_value).to eq('secondary')
|
||||||
expect(champ_datetime.value).to eq('2019-12-21T13:17:00+01:00')
|
expect(champ_datetime.value).to eq('2019-12-21T13:17:00+01:00')
|
||||||
expect(champ_repetition.champs.first.value).to eq('text')
|
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(dossier.reload.last_champ_private_updated_at).to eq(now)
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue