New Routes: add new_user/dossier_controller attestation

This commit is contained in:
Simon Lehericey 2017-06-29 14:18:59 +02:00 committed by Mathieu Magnin
parent 15b16f36b7
commit 1e661fa686
3 changed files with 31 additions and 0 deletions

View file

@ -43,4 +43,25 @@ describe NewUser::DossiersController, type: :controller do
end
end
end
describe 'attestation' do
before { sign_in(user) }
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, attestation: Attestation.new, user: user) }
it 'returns the attestation pdf' do
allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf)
expect(controller).to receive(:send_data)
.with('pdf content', filename: 'attestation.pdf', type: 'application/pdf') do
controller.render nothing: true
end
get :attestation, params: { dossier_id: dossier.id }
expect(response).to have_http_status(:success)
end
end
end
end