feat(routing): make routing engine work with epci champ
This commit is contained in:
parent
588143f9fd
commit
967139ec88
2 changed files with 26 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue