Attestation: fix missing_attachment

This commit is contained in:
Simon Lehericey 2017-06-16 14:10:08 +02:00
parent 58221c8e8a
commit 5c70d38a23
2 changed files with 11 additions and 7 deletions

View file

@ -114,8 +114,6 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
dossier = @facade.dossier
attestation_pdf = nil
case params[:process_action]
when "refuse"
next_step = "refuse"
@ -129,12 +127,15 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
next_step = "close"
notice = "Dossier traité avec succès."
template = dossier.procedure.closed_mail_template
if check_attestation_emailable(dossier)
attestation_pdf = dossier.attestation.pdf.read
end
end
dossier.next_step! 'gestionnaire', next_step, motivation
attestation_pdf = nil
if check_attestation_emailable(dossier)
attestation_pdf = dossier.attestation.pdf.read
end
flash.notice = notice
NotificationMailer.send_notification(dossier, template, attestation_pdf).deliver_now!

View file

@ -336,8 +336,11 @@ describe Backoffice::DossiersController, type: :controller do
let(:emailable) { false }
before do
fake_attestation = double(pdf: double(read: 'pdf', size: 2.megabytes), emailable?: emailable)
allow_any_instance_of(Dossier).to receive(:attestation).and_return(fake_attestation)
attestation = Attestation.new
allow(attestation).to receive(:pdf).and_return(double(read: 'pdf', size: 2.megabytes))
allow(attestation).to receive(:emailable?).and_return(emailable)
allow_any_instance_of(Dossier).to receive(:build_attestation).and_return(attestation)
end
context 'emailable' do