feat(routing): make routing engine work with region champ

This commit is contained in:
Eric Leroy-Terquem 2023-09-08 15:49:50 +02:00
parent e255bb9929
commit d37fb90b2f
2 changed files with 20 additions and 1 deletions

View file

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

View file

@ -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,