Add groupe_instructeur_label to export v2

This commit is contained in:
simon lehericey 2019-09-18 21:09:52 +02:00
parent f577484aa2
commit a2f82ab8be
2 changed files with 24 additions and 5 deletions

View file

@ -447,7 +447,7 @@ class Dossier < ApplicationRecord
end
def spreadsheet_columns
[
columns = [
['ID', id.to_s],
['Email', user.email],
['Civilité', individual&.gender],
@ -462,7 +462,13 @@ class Dossier < ApplicationRecord
['Traité le', :processed_at],
['Motivation de la décision', :motivation],
['Instructeurs', followers_instructeurs.map(&:email).join(' ')]
] + champs_for_export + annotations_for_export
]
if procedure.routee?
columns << ['Groupe instructeur', groupe_instructeur.label]
end
columns + champs_for_export + annotations_for_export
end
def champs_for_export

View file

@ -34,8 +34,8 @@ describe ProcedureExportV2Service do
context 'with dossier' do
let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :for_individual, procedure: procedure) }
it 'should have headers' do
expect(dossiers_sheet.headers).to eq([
let(:nominal_headers) do
[
"ID",
"Email",
"Civilité",
@ -74,7 +74,11 @@ describe ProcedureExportV2Service do
"siret",
"carte",
"text"
])
]
end
it 'should have headers' do
expect(dossiers_sheet.headers).to match(nominal_headers)
end
it 'should have data' do
@ -88,6 +92,15 @@ describe ProcedureExportV2Service do
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 procedure routee' do
before { procedure.groupe_instructeurs.create(label: '2') }
let(:routee_header) { nominal_headers.insert(nominal_headers.index('textarea'), 'Groupe instructeur') }
it { expect(dossiers_sheet.headers).to match(routee_header) }
it { expect(dossiers_sheet.data[0][dossiers_sheet.headers.index('Groupe instructeur')]).to eq('défaut') }
end
end
context 'with etablissement' do