fix: dossier projection for json column

This commit is contained in:
simon lehericey 2024-11-12 09:28:00 +01:00
parent 00302b858c
commit 6f010cd2c5
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 13 additions and 1 deletions

View file

@ -207,7 +207,7 @@ class DossierProjectionService
type_de_champ = stable_ids_and_types_de_champ_by_dossier_ids.fetch(champ.dossier_id, {})[champ.stable_id] type_de_champ = stable_ids_and_types_de_champ_by_dossier_ids.fetch(champ.dossier_id, {})[champ.stable_id]
if type_de_champ.present? && type_de_champ.type_champ == champ.last_write_type_champ if type_de_champ.present? && type_de_champ.type_champ == champ.last_write_type_champ
if column.is_a?(Columns::JSONPathColumn) if column.is_a?(Columns::JSONPathColumn)
column.get_value(champ) column.value(champ)
else else
type_de_champ.champ_value(champ) type_de_champ.champ_value(champ)
end end

View file

@ -238,6 +238,18 @@ describe DossierProjectionService do
end end
end end
context 'for a json column' do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret, libelle: 'siret' }]) }
let(:dossier) { create(:dossier, procedure:) }
let(:label) { "siret département" }
before do
dossier.project_champs_public.first.update(value_json: { 'departement_code': '38' })
end
it { is_expected.to eq('38') }
end
context 'for dossier corrections table' do context 'for dossier corrections table' do
let(:table) { 'dossier_corrections' } let(:table) { 'dossier_corrections' }
let(:column) { 'resolved_at' } let(:column) { 'resolved_at' }