diff --git a/app/models/logic/champ_value.rb b/app/models/logic/champ_value.rb index 4da360642..866c66ae0 100644 --- a/app/models/logic/champ_value.rb +++ b/app/models/logic/champ_value.rb @@ -46,7 +46,7 @@ class Logic::ChampValue < Logic::Term targeted_champ.selected_options when "Champs::DepartementChamp", "Champs::RegionChamp" targeted_champ.code - when "Champs::CommuneChamp" + when "Champs::CommuneChamp", "Champs::EpciChamp" targeted_champ.code_departement end end diff --git a/spec/models/routing_engine_spec.rb b/spec/models/routing_engine_spec.rb index 3b8c08e4f..676e7c7de 100644 --- a/spec/models/routing_engine_spec.rb +++ b/spec/models/routing_engine_spec.rb @@ -130,6 +130,31 @@ describe RoutingEngine, type: :model do end end + context 'with an epci type de champ' do + let(:procedure) do + create(:procedure, types_de_champ_public: [{ type: :epci }]).tap do |p| + p.groupe_instructeurs.create(label: 'a third group') + end + end + + let(:epci_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(epci_tdc.stable_id), constant('42'))) + dossier.champs.first.update_columns( + external_id: 244200895, + value: 'CC du Pilat Rhodanien', + value_json: { code_departement: '42' } + ) + end + + it do + is_expected.to eq(gi_2) + end + end + end + context 'routing rules priorities' do let(:procedure) do create(:procedure,