[FIX #492] switch to new attestation download system

This commit is contained in:
Simon Lehericey 2017-06-29 15:42:13 +02:00 committed by Mathieu Magnin
parent 4e6a8c5939
commit b1d96f4a94
4 changed files with 4 additions and 25 deletions

View file

@ -7,10 +7,6 @@ class Users::RecapitulatifController < UsersController
create_dossier_facade
end
def attestation
send_data(current_user_dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
def initiate
create_dossier_facade

View file

@ -11,4 +11,7 @@
= image_tag('pdf.svg', width: '20px')
%p.title= dossier.attestation.title
%p.delivery Délivrée le #{l(dossier.attestation.created_at, format: '%d %B %Y')}
%a.btn.btn-primary{ href: users_dossier_recapitulatif_attestation_path(dossier), target: '_blank' } Télécharger
- if user_signed_in?
= link_to 'Télécharger', dossier_attestation_path(dossier), target: '_blank', class: 'btn btn-primary'
- else
= link_to 'Télécharger', procedure_dossier_attestation_path(dossier.procedure, dossier), target: '_blank', class: 'btn btn-primary'

View file

@ -82,8 +82,6 @@ Rails.application.routes.draw do
get '/recapitulatif' => 'recapitulatif#show'
post '/recapitulatif/initiate' => 'recapitulatif#initiate'
get '/recapitulatif/attestation' => 'recapitulatif#attestation'
post '/commentaire' => 'commentaires#create'
resources :commentaires, only: [:index]

View file

@ -51,22 +51,4 @@ describe Users::RecapitulatifController, type: :controller do
end
end
end
describe 'Get #attestation' do
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, attestation: Attestation.new) }
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 }
end
end
end
end