feat(routing): make routing engine work with commune champ
This commit is contained in:
parent
370d853378
commit
46ff36c2bc
2 changed files with 21 additions and 0 deletions
|
@ -46,6 +46,8 @@ class Logic::ChampValue < Logic::Term
|
|||
targeted_champ.selected_options
|
||||
when "Champs::DepartementChamp", "Champs::RegionChamp"
|
||||
targeted_champ.code
|
||||
when "Champs::CommuneChamp"
|
||||
targeted_champ.code_departement
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -111,6 +111,25 @@ describe RoutingEngine, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a communes type de champ' do
|
||||
let(:procedure) do
|
||||
create(:procedure, types_de_champ_public: [{ type: :communes }]).tap do |p|
|
||||
p.groupe_instructeurs.create(label: 'a third group')
|
||||
end
|
||||
end
|
||||
|
||||
let(:communes_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(communes_tdc.stable_id), constant('92')))
|
||||
dossier.champs.first.update(value: 'Rueil-Malmaison', value_json: { code_postal: '92500', code_departement: '92' })
|
||||
end
|
||||
|
||||
it { is_expected.to eq(gi_2) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'routing rules priorities' do
|
||||
let(:procedure) do
|
||||
create(:procedure,
|
||||
|
|
Loading…
Reference in a new issue