diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index 1162beb0e..390555775 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -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 } ] diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index b2a640214..95010a657 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -4,12 +4,15 @@ 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) end let(:template_concern) do @@ -144,6 +147,12 @@ describe TagsSubstitutionConcern, type: :model do end end + context 'when the dossier has a service' do + let(:template) { 'Dossier traité par --nom du service--' } + + it { is_expected.to eq("Dossier traité par #{service.nom}") } + end + context 'when the dossier has a motivation' do let(:dossier) { create(:dossier, motivation: 'motivation') }