Merge pull request #1185 from sgmap/fix_1037-add_dossier_date_tags
[Fix #1037] Add date de dépôt and début d’instruction tags
This commit is contained in:
commit
ce8961a2dc
2 changed files with 38 additions and 5 deletions
|
@ -32,14 +32,28 @@ module TagsSubstitutionConcern
|
|||
description: 'Motivation facultative associée à la décision finale d’acceptation, refus ou classement sans suite',
|
||||
target: :motivation,
|
||||
dossier_termine_only: true },
|
||||
{ libelle: 'date de dépôt',
|
||||
description: 'Date du passage en construction du dossier par l’usager',
|
||||
lambda: -> (d) { format_date(d.en_construction_at) } },
|
||||
{ libelle: 'date de passage en instruction',
|
||||
description: '',
|
||||
lambda: -> (d) { format_date(d.en_instruction_at) } },
|
||||
{ libelle: 'date de décision',
|
||||
description: 'Date de la décision d’acceptation, refus, ou classement sans suite',
|
||||
lambda: -> (d) { d.processed_at.present? ? d.processed_at.localtime.strftime('%d/%m/%Y') : '' },
|
||||
lambda: -> (d) { format_date(d.processed_at) },
|
||||
dossier_termine_only: true },
|
||||
{ libelle: 'libellé procédure', description: '', lambda: -> (d) { d.procedure.libelle } },
|
||||
{ libelle: 'numéro du dossier', description: '', target: :id }]
|
||||
end
|
||||
|
||||
def format_date(date)
|
||||
if date.present?
|
||||
date.localtime.strftime('%d/%m/%Y')
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def individual_tags
|
||||
[{ libelle: 'civilité', description: 'M., Mme', target: :gender },
|
||||
{ libelle: 'nom', description: "nom de l'usager", target: :nom },
|
||||
|
|
|
@ -167,12 +167,31 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context "when the template has a date de décision tag" do
|
||||
let(:template) { '--date de décision--' }
|
||||
context "when using a date tag" do
|
||||
before do
|
||||
dossier.accepte!
|
||||
dossier.en_construction_at = DateTime.new(2001, 2, 3)
|
||||
dossier.en_instruction_at = DateTime.new(2004, 5, 6)
|
||||
dossier.processed_at = DateTime.new(2007, 8, 9)
|
||||
end
|
||||
|
||||
before { dossier.accepte! }
|
||||
context "with date de dépôt" do
|
||||
let(:template) { '--date de dépôt--' }
|
||||
|
||||
it { is_expected.to eq(DateTime.now.localtime.strftime('%d/%m/%Y')) }
|
||||
it { is_expected.to eq('03/02/2001') }
|
||||
end
|
||||
|
||||
context "with date de passage en instruction" do
|
||||
let(:template) { '--date de passage en instruction--' }
|
||||
|
||||
it { is_expected.to eq('06/05/2004') }
|
||||
end
|
||||
|
||||
context "with date de décision" do
|
||||
let(:template) { '--date de décision--' }
|
||||
|
||||
it { is_expected.to eq('09/08/2007') }
|
||||
end
|
||||
end
|
||||
|
||||
context "when the template has a libellé procédure tag" do
|
||||
|
|
Loading…
Add table
Reference in a new issue