Merge pull request #5143 from betagouv/remove-birthday-column

Export tableur : suppression de la colonne "Date de naissance"
This commit is contained in:
Keirua 2020-05-18 15:27:52 +02:00 committed by GitHub
commit 6cf2ca7cfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 13 deletions

View file

@ -626,9 +626,11 @@ class Dossier < ApplicationRecord
columns += [ columns += [
['Civilité', individual&.gender], ['Civilité', individual&.gender],
['Nom', individual&.nom], ['Nom', individual&.nom],
['Prénom', individual&.prenom], ['Prénom', individual&.prenom]
['Date de naissance', individual&.birthdate]
] ]
if procedure.ask_birthday
columns += [['Date de naissance', individual&.birthdate]]
end
elsif with_etablissement elsif with_etablissement
columns += [ columns += [
['Établissement SIRET', etablissement&.siret], ['Établissement SIRET', etablissement&.siret],

View file

@ -25,13 +25,13 @@ describe ProcedureExportService do
procedure.reload procedure.reload
end end
context 'dossiers' do describe 'sheets' do
it 'should have sheets' do it 'should have a sheet for each record type' do
expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis']) expect(subject.sheets.map(&:name)).to eq(['Dossiers', 'Etablissements', 'Avis'])
end end
end end
context 'with dossier' do describe 'Dossiers sheet' do
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure) } let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure) }
let(:nominal_headers) do let(:nominal_headers) do
@ -41,7 +41,6 @@ describe ProcedureExportService do
"Civilité", "Civilité",
"Nom", "Nom",
"Prénom", "Prénom",
"Date de naissance",
"Archivé", "Archivé",
"État du dossier", "État du dossier",
"Dernière mise à jour le", "Dernière mise à jour le",
@ -88,23 +87,32 @@ describe ProcedureExportService do
# SimpleXlsxReader is transforming datetimes in utc... It is only used in test so we just hack around. # SimpleXlsxReader is transforming datetimes in utc... It is only used in test so we just hack around.
offset = dossier.en_construction_at.utc_offset offset = dossier.en_construction_at.utc_offset
en_construction_at = Time.zone.at(dossiers_sheet.data[0][9] - 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][10] - 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_construction_at).to eq(dossier.en_construction_at.round)
expect(en_instruction_at).to eq(dossier.en_instruction_at.round) expect(en_instruction_at).to eq(dossier.en_instruction_at.round)
end 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 context 'with a procedure routee' do
before { procedure.groupe_instructeurs.create(label: '2') } before { procedure.groupe_instructeurs.create(label: '2') }
let(:routee_header) { nominal_headers.insert(nominal_headers.index('textarea'), 'Groupe instructeur') } let(:routee_headers) { nominal_headers.insert(nominal_headers.index('textarea'), 'Groupe instructeur') }
it { expect(dossiers_sheet.headers).to match(routee_header) } it { expect(dossiers_sheet.headers).to match(routee_headers) }
it { expect(dossiers_sheet.data[0][dossiers_sheet.headers.index('Groupe instructeur')]).to eq('défaut') } it { expect(dossiers_sheet.data[0][dossiers_sheet.headers.index('Groupe instructeur')]).to eq('défaut') }
end end
end end
context 'with etablissement' do describe 'Etablissement sheet' do
let(:procedure) { create(:procedure, :published, :with_all_champs) } let(:procedure) { create(:procedure, :published, :with_all_champs) }
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_entreprise, procedure: procedure) } let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_entreprise, procedure: procedure) }
@ -284,7 +292,7 @@ describe ProcedureExportService do
end end
end end
context 'with avis' do describe 'Avis sheet' do
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure) } let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure) }
let!(:avis) { create(:avis, :with_answer, dossier: dossier) } let!(:avis) { create(:avis, :with_answer, dossier: dossier) }
@ -305,7 +313,7 @@ describe ProcedureExportService do
end end
end end
context 'with repetitions' do describe 'Repetitions sheet' do
let!(:dossiers) do let!(:dossiers) do
[ [
create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure), create(:dossier, :en_instruction, :with_all_champs, :with_individual, procedure: procedure),