From b63fa0e6b884b0e492175bbada6e9bb8064d39c5 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 13 May 2020 15:57:56 +0200 Subject: [PATCH] dossier: remove "Birthdate" column from export --- app/models/dossier.rb | 6 ++++-- spec/services/procedure_export_service_spec.rb | 14 +++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 292a5eae3..87f2d27cd 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -626,9 +626,11 @@ class Dossier < ApplicationRecord columns += [ ['Civilité', individual&.gender], ['Nom', individual&.nom], - ['Prénom', individual&.prenom], - ['Date de naissance', individual&.birthdate] + ['Prénom', individual&.prenom] ] + if procedure.ask_birthday + columns += [['Date de naissance', individual&.birthdate]] + end elsif with_etablissement columns += [ ['Établissement SIRET', etablissement&.siret], diff --git a/spec/services/procedure_export_service_spec.rb b/spec/services/procedure_export_service_spec.rb index 5a29e4a3a..e21237946 100644 --- a/spec/services/procedure_export_service_spec.rb +++ b/spec/services/procedure_export_service_spec.rb @@ -41,7 +41,6 @@ describe ProcedureExportService do "Civilité", "Nom", "Prénom", - "Date de naissance", "Archivé", "État du dossier", "Dernière mise à jour le", @@ -88,12 +87,21 @@ describe ProcedureExportService do # SimpleXlsxReader is transforming datetimes in utc... It is only used in test so we just hack around. offset = dossier.en_construction_at.utc_offset - en_construction_at = Time.zone.at(dossiers_sheet.data[0][9] - offset.seconds) - en_instruction_at = Time.zone.at(dossiers_sheet.data[0][10] - offset.seconds) + en_construction_at = Time.zone.at(dossiers_sheet.data[0][8] - offset.seconds) + en_instruction_at = Time.zone.at(dossiers_sheet.data[0][9] - offset.seconds) expect(en_construction_at).to eq(dossier.en_construction_at.round) expect(en_instruction_at).to eq(dossier.en_instruction_at.round) end + context 'with a birthdate' do + before { procedure.update(ask_birthday: true) } + + let(:birthdate_headers) { nominal_headers.insert(nominal_headers.index('Archivé'), 'Date de naissance') } + + it { expect(dossiers_sheet.headers).to match(birthdate_headers) } + it { expect(dossiers_sheet.data[0][dossiers_sheet.headers.index('Date de naissance')]).to be_a(Date) } + end + context 'with a procedure routee' do before { procedure.groupe_instructeurs.create(label: '2') }