feat(routing): can create simple routing with pays tdc
This commit is contained in:
parent
b29893a843
commit
30aa0b71d0
3 changed files with 25 additions and 0 deletions
|
@ -60,6 +60,10 @@ module Administrateurs
|
|||
rule_operator = :ds_eq
|
||||
tdc_options = APIGeoService.regions.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
||||
create_groups_from_territorial_tdc(tdc_options, stable_id, rule_operator)
|
||||
when TypeDeChamp.type_champs.fetch(:pays)
|
||||
rule_operator = :ds_eq
|
||||
tdc_options = APIGeoService.countries.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
||||
create_groups_from_territorial_tdc(tdc_options, stable_id, rule_operator)
|
||||
when TypeDeChamp.type_champs.fetch(:drop_down_list)
|
||||
tdc_options = tdc.drop_down_options.reject(&:empty?)
|
||||
create_groups_from_drop_down_list_tdc(tdc_options, stable_id)
|
||||
|
|
|
@ -115,6 +115,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
type_champs.fetch(:communes),
|
||||
type_champs.fetch(:departements),
|
||||
type_champs.fetch(:regions),
|
||||
type_champs.fetch(:pays),
|
||||
type_champs.fetch(:epci),
|
||||
type_champs.fetch(:address)
|
||||
]
|
||||
|
|
|
@ -959,6 +959,26 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a pays type de champ' do
|
||||
let!(:procedure3) do
|
||||
create(:procedure,
|
||||
types_de_champ_public: [{ type: :pays }],
|
||||
administrateurs: [admin])
|
||||
end
|
||||
|
||||
let!(:pays_tdc) { procedure3.draft_revision.types_de_champ.first }
|
||||
|
||||
before { post :create_simple_routing, params: { procedure_id: procedure3.id, create_simple_routing: { stable_id: pays_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("AD – Andorre")
|
||||
expect(procedure3.reload.defaut_groupe_instructeur.routing_rule).to eq(ds_eq(champ_value(pays_tdc.stable_id), constant('AD')))
|
||||
expect(procedure3.routing_enabled).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a communes type de champ' do
|
||||
let!(:procedure3) do
|
||||
create(:procedure,
|
||||
|
|
Loading…
Reference in a new issue