diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index 9d470d500..88dd4d2f8 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -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 diff --git a/app/views/dossiers/_attestation.html.haml b/app/views/dossiers/_attestation.html.haml index b6c4dc3ce..dc77bc5f2 100644 --- a/app/views/dossiers/_attestation.html.haml +++ b/app/views/dossiers/_attestation.html.haml @@ -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' diff --git a/config/routes.rb b/config/routes.rb index 32ced0aae..c67ba0dc9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb index 326699f3e..120e2e344 100644 --- a/spec/controllers/users/recapitulatif_controller_spec.rb +++ b/spec/controllers/users/recapitulatif_controller_spec.rb @@ -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