Merge pull request #4805 from betagouv/4785-tag-groupe-instructeur
4785 - Ajout d'un tag 'groupe instructeur'
This commit is contained in:
commit
bc1c085e5e
2 changed files with 39 additions and 1 deletions
|
@ -130,6 +130,15 @@ module TagsSubstitutionConcern
|
|||
}
|
||||
]
|
||||
|
||||
ROUTAGE_TAGS = [
|
||||
{
|
||||
libelle: 'groupe instructeur',
|
||||
description: 'Le groupe instructeur en charge du dossier',
|
||||
lambda: -> (d) { d.groupe_instructeur.label },
|
||||
available_for_states: Dossier::SOUMIS
|
||||
}
|
||||
]
|
||||
|
||||
def tags
|
||||
if procedure.for_individual?
|
||||
identity_tags = INDIVIDUAL_TAGS
|
||||
|
@ -137,7 +146,12 @@ module TagsSubstitutionConcern
|
|||
identity_tags = ENTREPRISE_TAGS
|
||||
end
|
||||
|
||||
filter_tags(identity_tags + dossier_tags + champ_public_tags + champ_private_tags)
|
||||
routage_tags = []
|
||||
if procedure.routee?
|
||||
routage_tags = ROUTAGE_TAGS
|
||||
end
|
||||
|
||||
filter_tags(identity_tags + dossier_tags + champ_public_tags + champ_private_tags + routage_tags)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -207,6 +221,7 @@ module TagsSubstitutionConcern
|
|||
[champ_public_tags, dossier.champs],
|
||||
[champ_private_tags, dossier.champs_private],
|
||||
[dossier_tags, dossier],
|
||||
[ROUTAGE_TAGS, dossier],
|
||||
[INDIVIDUAL_TAGS, dossier.individual],
|
||||
[ENTREPRISE_TAGS, dossier.etablissement&.entreprise]
|
||||
]
|
||||
|
|
|
@ -70,6 +70,29 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the template use the groupe instructeur tags' do
|
||||
let(:template) { '--groupe instructeur--' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: etablissement, state: state) }
|
||||
context 'and the dossier has a groupe instructeur' do
|
||||
label = 'Ville de Bordeaux'
|
||||
before do
|
||||
gi = procedure.groupe_instructeurs.create(label: label)
|
||||
gi.dossiers << dossier
|
||||
dossier.update(groupe_instructeur: gi)
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.routee?).to eq(true) }
|
||||
it { is_expected.to eq(label) }
|
||||
end
|
||||
|
||||
context 'and the dossier has no groupe instructeur' do
|
||||
it { expect(procedure.routee?).to eq(false) }
|
||||
it { is_expected.to eq('défaut') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the procedure has a type de champ named libelleA et libelleB' do
|
||||
let(:types_de_champ) do
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue