feat(attestation): support last champ updated at as tag

closes #9825
This commit is contained in:
Colin Darie 2024-09-12 17:08:20 +02:00
parent 5b268fff29
commit 861f7359b1
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
3 changed files with 33 additions and 10 deletions

View file

@ -102,6 +102,13 @@ module TagsSubstitutionConcern
lambda: -> (d) { format_date(d.processed_at) }, lambda: -> (d) { format_date(d.processed_at) },
available_for_states: Dossier::TERMINE available_for_states: Dossier::TERMINE
}, },
{
id: 'dossier_last_champ_updated_at',
libelle: 'date de mise à jour',
description: 'Date de dernière mise à jour dun champ du dossier',
lambda: -> (d) { format_date(d.last_champ_updated_at) },
available_for_states: Dossier::SOUMIS
},
{ {
id: 'dossier_procedure_libelle', id: 'dossier_procedure_libelle',
libelle: 'libellé démarche', libelle: 'libellé démarche',

View file

@ -375,13 +375,17 @@ describe TagsSubstitutionConcern, type: :model do
context "when using a date tag" do context "when using a date tag" do
before do before do
Timecop.freeze(Time.zone.local(2001, 2, 3)) travel_to Time.zone.local(2001, 2, 3)
dossier.passer_en_construction! dossier.passer_en_construction!
Timecop.freeze(Time.zone.local(2004, 5, 6))
travel_to Time.zone.local(2003, 1, 3)
dossier.touch(:last_champ_updated_at)
travel_to Time.zone.local(2004, 5, 6)
dossier.passer_en_instruction!(instructeur: instructeur) dossier.passer_en_instruction!(instructeur: instructeur)
Timecop.freeze(Time.zone.local(2007, 8, 9))
travel_to Time.zone.local(2007, 8, 9)
dossier.accepter!(instructeur: instructeur) dossier.accepter!(instructeur: instructeur)
Timecop.return
end end
context "with date de dépôt" do context "with date de dépôt" do
@ -401,6 +405,12 @@ describe TagsSubstitutionConcern, type: :model do
it { is_expected.to eq('09/08/2007') } it { is_expected.to eq('09/08/2007') }
end end
context "with date last ,champ updated at" do
let(:template) { '--date de mise à jour--' }
it { is_expected.to eq('03/01/2003') }
end
end end
context "when the template has a libellé démarche tag" do context "when the template has a libellé démarche tag" do

View file

@ -67,24 +67,30 @@ describe ExportTemplate do
context 'for entreprise procedure' do context 'for entreprise procedure' do
let(:for_individual) { false } let(:for_individual) { false }
let(:expected_tags) do let(:expected_tags) do
['entreprise_siren', 'entreprise_numero_tva_intracommunautaire', 'entreprise_siret_siege_social', 'entreprise_raison_sociale', 'entreprise_adresse', 'dossier_depose_at', 'dossier_procedure_libelle', 'dossier_service_name', 'dossier_number', 'dossier_groupe_instructeur'] [
'entreprise_siren', 'entreprise_numero_tva_intracommunautaire', 'entreprise_siret_siege_social', 'entreprise_raison_sociale', 'entreprise_adresse',
'dossier_depose_at', 'dossier_procedure_libelle', 'dossier_service_name', 'dossier_number', 'dossier_groupe_instructeur', 'dossier_last_champ_updated_at'
]
end end
it do it do
expect(export_template.tags.map { _1[:id] }).to eq(expected_tags) expect(export_template.tags.map { _1[:id] }).to match_array(expected_tags)
expect(export_template.pj_tags.map { _1[:id] }).to eq(expected_tags + ['original-filename']) expect(export_template.pj_tags.map { _1[:id] }).to match_array(expected_tags + ['original-filename'])
end end
end end
context 'for individual procedure' do context 'for individual procedure' do
let(:for_individual) { true } let(:for_individual) { true }
let(:expected_tags) do let(:expected_tags) do
['individual_gender', 'individual_last_name', 'individual_first_name', 'dossier_depose_at', 'dossier_procedure_libelle', 'dossier_service_name', 'dossier_number', 'dossier_groupe_instructeur'] [
'individual_gender', 'individual_last_name', 'individual_first_name',
'dossier_depose_at', 'dossier_procedure_libelle', 'dossier_service_name', 'dossier_number', 'dossier_groupe_instructeur', 'dossier_last_champ_updated_at'
]
end end
it do it do
expect(export_template.tags.map { _1[:id] }).to eq(expected_tags) expect(export_template.tags.map { _1[:id] }).to match_array(expected_tags)
expect(export_template.pj_tags.map { _1[:id] }).to eq(expected_tags + ['original-filename']) expect(export_template.pj_tags.map { _1[:id] }).to match_array(expected_tags + ['original-filename'])
end end
end end
end end