Merge pull request #8203 from mfo/US/fix-export-pjs

correctif(export.pjs): la liste des pjs doit etre une chaine de caractère pas un tableau
This commit is contained in:
mfo 2022-12-06 15:39:35 +01:00 committed by GitHub
commit 342a7b8ee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View file

@ -43,7 +43,7 @@ class Champs::PieceJustificativeChamp < Champ
end
def for_export
piece_justificative_file.map { _1.filename.to_s }
piece_justificative_file.map { _1.filename.to_s }.join(', ')
end
def for_api

View file

@ -43,11 +43,11 @@ describe Champs::PieceJustificativeChamp do
let(:champ_pj) { create(:champ_piece_justificative) }
subject { champ_pj.for_export }
it { is_expected.to match_array(['toto.txt']) }
it { is_expected.to eq('toto.txt') }
context 'without attached file' do
before { champ_pj.piece_justificative_file.purge }
it { is_expected.to eq([]) }
it { is_expected.to eq('') }
end
end

View file

@ -98,6 +98,7 @@ describe ProcedureExportService do
offset = dossier.depose_at.utc_offset
depose_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(dossiers_sheet.data.first.size).to eq(nominal_headers.size)
expect(depose_at).to eq(dossier.depose_at.round)
expect(en_instruction_at).to eq(dossier.en_instruction_at.round)
end
@ -119,6 +120,17 @@ describe ProcedureExportService do
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') }
end
context 'with a dossier having multiple pjs' do
let!(:dossier_2) { create(:dossier, :en_instruction, :with_populated_champs, :with_individual, procedure: procedure) }
before do
dossier_2.champs_public
.find { _1.is_a? Champs::PieceJustificativeChamp }
.piece_justificative_file
.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
end
it { expect(dossiers_sheet.data.first.size).to eq(nominal_headers.size) }
end
end
describe 'Etablissement sheet' do