From 236f73f838fb21723b771fc42f9a65cb57ae21fc Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Wed, 20 Feb 2019 11:48:08 +0100 Subject: [PATCH 1/2] ajout d'une balise pour le nom du service --- app/models/concerns/tags_substitution_concern.rb | 6 ++++++ spec/models/concern/tags_substitution_concern_spec.rb | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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') } From 71bff0812c61f258aa68445ca645188d46d31f3c Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 21 Feb 2019 11:24:56 +0000 Subject: [PATCH 2/2] =?UTF-8?q?ajout=20d'un=20test=20pour=20caract=C3=A9ri?= =?UTF-8?q?ser=20le=20cas=20service=20=3D=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concern/tags_substitution_concern_spec.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index 95010a657..6ae053824 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -12,7 +12,8 @@ describe TagsSubstitutionConcern, type: :model do types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private, for_individual: for_individual, - service: service) + service: service, + organisation: nil) end let(:template_concern) do @@ -147,10 +148,17 @@ describe TagsSubstitutionConcern, type: :model do end end - context 'when the dossier has a service' do + context 'when the user requests the service' do let(:template) { 'Dossier traité par --nom du service--' } - it { is_expected.to eq("Dossier traité par #{service.nom}") } + 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