Merge pull request #453 from sgmap/Fix_attestation_attachment_with_remote_storage

Attestation: fix mail attachment when the files are remotely stored
This commit is contained in:
LeSim 2017-06-19 14:55:24 +02:00 committed by GitHub
commit 8222a7dc28
2 changed files with 5 additions and 0 deletions

View file

@ -131,6 +131,10 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
dossier.next_step! 'gestionnaire', next_step, motivation
# needed to force Carrierwave to provide dossier.attestation.pdf.read
# when the Feature.remote_storage is true, otherwise pdf.read is a closed stream.
dossier.reload
attestation_pdf = nil
if check_attestation_emailable(dossier)
attestation_pdf = dossier.attestation.pdf.read

View file

@ -340,6 +340,7 @@ describe Backoffice::DossiersController, type: :controller do
allow(attestation).to receive(:pdf).and_return(double(read: 'pdf', size: 2.megabytes))
allow(attestation).to receive(:emailable?).and_return(emailable)
expect_any_instance_of(Dossier).to receive(:reload)
allow_any_instance_of(Dossier).to receive(:build_attestation).and_return(attestation)
end