feat(routing): can create simple routing with address tdc

This commit is contained in:
Eric Leroy-Terquem 2024-02-21 11:31:49 +01:00
parent 8b4b4d7cb7
commit fade633828
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
3 changed files with 23 additions and 2 deletions

View file

@ -53,7 +53,7 @@ module Administrateurs
tdc_options = APIGeoService.departements.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] }
rule_operator = :ds_eq
create_groups_from_territorial_tdc(tdc_options, stable_id, rule_operator)
when TypeDeChamp.type_champs.fetch(:communes), TypeDeChamp.type_champs.fetch(:epci)
when TypeDeChamp.type_champs.fetch(:communes), TypeDeChamp.type_champs.fetch(:epci), TypeDeChamp.type_champs.fetch(:address)
tdc_options = APIGeoService.departements.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] }
rule_operator = :ds_in_departement
create_groups_from_territorial_tdc(tdc_options, stable_id, rule_operator)

View file

@ -117,7 +117,8 @@ class TypeDeChamp < ApplicationRecord
type_champs.fetch(:communes),
type_champs.fetch(:departements),
type_champs.fetch(:regions),
type_champs.fetch(:epci)
type_champs.fetch(:epci),
type_champs.fetch(:address)
]
PRIVATE_ONLY_TYPES = [

View file

@ -933,6 +933,26 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
expect(procedure3.routing_enabled).to be_truthy
end
end
context 'with an address type de champ' do
let!(:procedure3) do
create(:procedure,
types_de_champ_public: [{ type: :address }],
administrateurs: [admin])
end
let!(:address_tdc) { procedure3.draft_revision.types_de_champ.first }
before { post :create_simple_routing, params: { procedure_id: procedure3.id, create_simple_routing: { stable_id: address_tdc.stable_id } } }
it do
expect(response).to redirect_to(admin_procedure_groupe_instructeurs_path(procedure3))
expect(flash.notice).to eq 'Les groupes instructeurs ont été ajoutés'
expect(procedure3.groupe_instructeurs.pluck(:label)).to include("01 Ain")
expect(procedure3.reload.defaut_groupe_instructeur.routing_rule).to eq(ds_in_departement(champ_value(address_tdc.stable_id), constant('01')))
expect(procedure3.routing_enabled).to be_truthy
end
end
end
describe '#wizard' do