generate pdf export inside pieces_justificatives_service

This commit is contained in:
Christophe Robillard 2021-03-29 21:45:46 +02:00
parent c25f3c79d9
commit fba0d78153
7 changed files with 41 additions and 34 deletions

View file

@ -712,13 +712,6 @@ describe Instructeurs::DossiersController, type: :controller do
dossier_id: dossier.id
}
end
context 'when zip download is disabled through flipflop' do
it 'is forbidden' do
subject
expect(response).to have_http_status(:forbidden)
end
end
end
describe "#delete_dossier" do

View file

@ -12,6 +12,8 @@ feature 'Inviting an expert:', js: true do
context 'as an Instructeur' do
scenario 'I can invite an expert' do
allow(ClamavService).to receive(:safe_file?).and_return(true)
# assign instructeur to linked dossier
instructeur.assign_to_procedure(linked_dossier.procedure)

View file

@ -165,10 +165,10 @@ feature 'Instructing a dossier:', js: true do
expect(DownloadHelpers.download).to include "dossier-#{dossier.id}.zip"
expect(files.size).to be 3
expect(files[0].filename.include?('piece_justificative_0')).to be_truthy
expect(files[0].uncompressed_size).to be File.size(path)
expect(files[1].filename.include?('horodatage/operation')).to be_truthy
expect(files[2].filename.include?('dossier/export')).to be_truthy
expect(files[0].filename.include?('export')).to be_truthy
expect(files[1].filename.include?('piece_justificative_0')).to be_truthy
expect(files[1].uncompressed_size).to be File.size(path)
expect(files[2].filename.include?('horodatage/operation')).to be_truthy
end
scenario 'A instructeur can download an archive containing several identical attachments' do
@ -180,13 +180,13 @@ feature 'Instructing a dossier:', js: true do
expect(DownloadHelpers.download).to include "dossier-#{dossier.id}.zip"
expect(files.size).to be 4
expect(files[0].filename.include?('piece_justificative_0')).to be_truthy
expect(files[0].filename.include?('export')).to be_truthy
expect(files[1].filename.include?('piece_justificative_0')).to be_truthy
expect(files[0].filename).not_to eq files[1].filename
expect(files[0].uncompressed_size).to be File.size(path)
expect(files[2].filename.include?('piece_justificative_0')).to be_truthy
expect(files[1].filename).not_to eq files[2].filename
expect(files[1].uncompressed_size).to be File.size(path)
expect(files[2].filename.include?('horodatage/operation')).to be_truthy
expect(files[3].filename.include?('dossier/export')).to be_truthy
expect(files[2].uncompressed_size).to be File.size(path)
expect(files[3].filename.include?('horodatage/operation')).to be_truthy
end
before { DownloadHelpers.clear_downloads }

View file

@ -16,7 +16,12 @@ describe PiecesJustificativesService do
# to be exported
it 'ensures no titre identite is given' do
expect(champ_identite.piece_justificative_file).to be_attached
expect(subject).to eq([])
expect(subject.any? { |piece| piece.name == 'piece_justificative_file' }).to be_falsy
end
it 'returns export pdf of the dossier' do
expect(champ_identite.piece_justificative_file).to be_attached
expect(subject.any? { |piece| piece.name == 'pdf_export_for_instructeur' }).to be_truthy
end
end
end