download a dossier as zip with all attachments

This commit is contained in:
clemkeirua 2019-07-01 15:55:37 +02:00
parent 5a70ae7a8f
commit 25f81f1d3c
14 changed files with 194 additions and 2 deletions

View file

@ -20,6 +20,9 @@ describe PiecesJustificativesService do
let(:errors) { PiecesJustificativesService.upload!(dossier, user, hash) }
let(:tpjs) { [tpj_not_mandatory] }
let(:attachment_list) { PiecesJustificativesService.liste_pieces_justificatives(dossier) }
let(:poids_total) { PiecesJustificativesService.pieces_justificatives_total_size(dossier) }
describe 'self.upload!' do
context 'when no params are given' do
it { expect(errors).to eq([]) }
@ -81,12 +84,30 @@ describe PiecesJustificativesService do
before :each do
# we are messing around piece_justificative
# because directly doubling carrierwave params seems complicated
piece_justificative_double = double(type_de_piece_justificative: tpj_mandatory)
expect(dossier).to receive(:pieces_justificatives).and_return([piece_justificative_double])
end
it { expect(errors).to match([]) }
it {
expect(errors).to match([])
}
end
end
describe '#attachment_list' do
context 'when no piece_justificative is present' do
it { expect(attachment_list).to match([]) }
it { expect(poids_total).to be 0 }
end
context 'when there is a piece_justificative' do
let (:pj) { create(:champ, :piece_justificative, :with_piece_justificative_file) }
before do
dossier.champs = [pj]
end
it { expect(attachment_list).not_to be_empty }
it { expect(poids_total).to be pj.piece_justificative_file.byte_size }
end
end