Merge pull request #3484 from Keirua/feat/3463-balise-nom-service

#3463 - Ajout d'une balise pour le nom du service
This commit is contained in:
Pierre de La Morinerie 2019-02-21 12:50:03 +01:00 committed by GitHub
commit d3ab6f8619
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -40,6 +40,12 @@ module TagsSubstitutionConcern
description: '',
target: :id,
available_for_states: Dossier::SOUMIS
},
{
libelle: 'nom du service',
description: 'Le nom du service instructeur qui traite le dossier',
lambda: -> (d) { d.procedure.organisation_name || '' },
available_for_states: Dossier::SOUMIS
}
]

View file

@ -4,12 +4,16 @@ describe TagsSubstitutionConcern, type: :model do
let(:for_individual) { false }
let(:state) { Dossier.states.fetch(:accepte) }
let(:service) { create(:service, nom: 'Service instructeur') }
let(:procedure) do
create(:procedure,
libelle: 'Une magnifique démarche',
types_de_champ: types_de_champ,
types_de_champ_private: types_de_champ_private,
for_individual: for_individual)
for_individual: for_individual,
service: service,
organisation: nil)
end
let(:template_concern) do
@ -144,6 +148,19 @@ describe TagsSubstitutionConcern, type: :model do
end
end
context 'when the user requests the service' do
let(:template) { 'Dossier traité par --nom du service--' }
context 'and there is a service' do
it { is_expected.to eq("Dossier traité par #{service.nom}") }
end
context 'and there is no service yet' do
let(:service) { nil }
it { is_expected.to eq("Dossier traité par ") }
end
end
context 'when the dossier has a motivation' do
let(:dossier) { create(:dossier, motivation: 'motivation') }