From 6f010cd2c52089a2daf37f131cdb8523777607fa Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 12 Nov 2024 09:28:00 +0100 Subject: [PATCH] fix: dossier projection for json column --- app/services/dossier_projection_service.rb | 2 +- spec/services/dossier_projection_service_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/services/dossier_projection_service.rb b/app/services/dossier_projection_service.rb index c6826dfb7..40705ed17 100644 --- a/app/services/dossier_projection_service.rb +++ b/app/services/dossier_projection_service.rb @@ -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] if type_de_champ.present? && type_de_champ.type_champ == champ.last_write_type_champ if column.is_a?(Columns::JSONPathColumn) - column.get_value(champ) + column.value(champ) else type_de_champ.champ_value(champ) end diff --git a/spec/services/dossier_projection_service_spec.rb b/spec/services/dossier_projection_service_spec.rb index af4969f8f..c9168eb39 100644 --- a/spec/services/dossier_projection_service_spec.rb +++ b/spec/services/dossier_projection_service_spec.rb @@ -238,6 +238,18 @@ describe DossierProjectionService do 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 let(:table) { 'dossier_corrections' } let(:column) { 'resolved_at' }