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:
commit
342a7b8ee4
3 changed files with 15 additions and 3 deletions
|
@ -43,7 +43,7 @@ class Champs::PieceJustificativeChamp < Champ
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_export
|
def for_export
|
||||||
piece_justificative_file.map { _1.filename.to_s }
|
piece_justificative_file.map { _1.filename.to_s }.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def for_api
|
def for_api
|
||||||
|
|
|
@ -43,11 +43,11 @@ describe Champs::PieceJustificativeChamp do
|
||||||
let(:champ_pj) { create(:champ_piece_justificative) }
|
let(:champ_pj) { create(:champ_piece_justificative) }
|
||||||
subject { champ_pj.for_export }
|
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
|
context 'without attached file' do
|
||||||
before { champ_pj.piece_justificative_file.purge }
|
before { champ_pj.piece_justificative_file.purge }
|
||||||
it { is_expected.to eq([]) }
|
it { is_expected.to eq('') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ describe ProcedureExportService do
|
||||||
offset = dossier.depose_at.utc_offset
|
offset = dossier.depose_at.utc_offset
|
||||||
depose_at = Time.zone.at(dossiers_sheet.data[0][8] - offset.seconds)
|
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)
|
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(depose_at).to eq(dossier.depose_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
|
||||||
|
@ -119,6 +120,17 @@ describe ProcedureExportService do
|
||||||
it { expect(dossiers_sheet.headers).to match(routee_headers) }
|
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
|
||||||
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
describe 'Etablissement sheet' do
|
describe 'Etablissement sheet' do
|
||||||
|
|
Loading…
Reference in a new issue