From d37fb90b2f34df5cdfeb5f94fdde1811cf4d84fb Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Fri, 8 Sep 2023 15:49:50 +0200 Subject: [PATCH] feat(routing): make routing engine work with region champ --- app/models/logic/champ_value.rb | 2 +- spec/models/routing_engine_spec.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models/logic/champ_value.rb b/app/models/logic/champ_value.rb index 4a1c9dcc2..e3d6985ff 100644 --- a/app/models/logic/champ_value.rb +++ b/app/models/logic/champ_value.rb @@ -44,7 +44,7 @@ class Logic::ChampValue < Logic::Term targeted_champ.selected when "Champs::MultipleDropDownListChamp" targeted_champ.selected_options - when "Champs::DepartementChamp" + when "Champs::DepartementChamp", "Champs::RegionChamp" targeted_champ.code end end diff --git a/spec/models/routing_engine_spec.rb b/spec/models/routing_engine_spec.rb index 38468ebb6..8d6574d4a 100644 --- a/spec/models/routing_engine_spec.rb +++ b/spec/models/routing_engine_spec.rb @@ -92,6 +92,25 @@ describe RoutingEngine, type: :model do end end + context 'with a regions type de champ' do + let(:procedure) do + create(:procedure, types_de_champ_public: [{ type: :regions }]).tap do |p| + p.groupe_instructeurs.create(label: 'a third group') + end + end + + let(:regions_tdc) { procedure.draft_revision.types_de_champ.first } + + context 'with a matching rule' do + before do + gi_2.update(routing_rule: ds_eq(champ_value(regions_tdc.stable_id), constant('04'))) + dossier.champs.first.update(value: 'La RĂ©union') + end + + it { is_expected.to eq(gi_2) } + end + end + context 'routing rules priorities' do let(:procedure) do create(:procedure,