[Fix #196] Recapitulatif: user can download its attestation

This commit is contained in:
Simon Lehericey 2017-05-31 16:29:51 +02:00
parent 602527a09d
commit 671a0575ce
9 changed files with 75 additions and 2 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="550.801" height="550.801" viewBox="0 0 550.801 550.801"><path d="M160.381 282.225c0-14.832-10.299-23.684-28.474-23.684-7.414 0-12.437.715-15.071 1.432V307.6c3.114.707 6.942.949 12.192.949 19.391 0 31.353-9.809 31.353-26.324zM272.875 259.019c-8.145 0-13.397.717-16.519 1.435v105.523c3.116.729 8.142.729 12.69.729 33.017.231 54.554-17.946 54.554-56.474.242-33.513-19.385-51.213-50.725-51.213z"/><path d="M488.426 197.019H475.2v-63.816c0-.398-.063-.799-.116-1.202-.021-2.534-.827-5.023-2.562-6.995L366.325 3.694c-.032-.031-.063-.042-.085-.076-.633-.707-1.371-1.295-2.151-1.804a9.495 9.495 0 0 0-.706-.419 11.131 11.131 0 0 0-2.131-.896c-.2-.056-.38-.138-.58-.19A10.774 10.774 0 0 0 358.193 0H97.2C85.282 0 75.6 9.693 75.6 21.601v175.413H62.377c-17.049 0-30.873 13.818-30.873 30.873v160.545c0 17.043 13.824 30.87 30.873 30.87h13.224V529.2c0 11.907 9.682 21.601 21.6 21.601h356.4c11.907 0 21.6-9.693 21.6-21.601V419.302h13.226c17.044 0 30.871-13.827 30.871-30.87v-160.54c-.001-17.054-13.828-30.873-30.872-30.873zM97.2 21.605h250.193v110.513c0 5.967 4.841 10.8 10.8 10.8H453.6v54.108H97.2V21.605zm265.159 287.418c0 30.876-11.243 52.165-26.82 65.333-16.971 14.117-42.82 20.814-74.396 20.814-18.9 0-32.297-1.197-41.401-2.389V234.365c13.399-2.149 30.878-3.346 49.304-3.346 30.612 0 50.478 5.508 66.039 17.226 16.743 12.445 27.274 32.302 27.274 60.778zM80.7 393.499V234.365c11.241-1.904 27.042-3.346 49.296-3.346 22.491 0 38.527 4.308 49.291 12.928 10.292 8.131 17.215 21.534 17.215 37.328 0 15.799-5.25 29.198-14.829 38.285-12.442 11.728-30.865 16.996-52.407 16.996-4.778 0-9.1-.243-12.435-.723v57.67H80.7v-.004zm372.901 129.854H97.2V419.302h356.4v104.051zm31.297-261.226h-61.989v36.851h57.913v29.674h-57.913V393.5h-36.593V232.216h98.582v29.911z"/></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -45,6 +45,7 @@
// = require typeahead
// = require users
// = require attestation_template_edit
// = require attestation_recapitulatif
// = require_self
// = require bootstrap-datepicker3

View file

@ -0,0 +1,31 @@
#attestation-recapitulatif {
margin-top: 40px;
.details {
padding: 15px;
display: flex;
align-items: center;
justify-content: space-between;
background-color: #FFFFFF;
.left {
position: relative;
padding-left: 30px;
img {
position: absolute;
left: 0px;
top: 15px;
}
.title {
font-weight: bold;
margin: 0;
}
.delivery {
color: #999999;
}
}
}
}

View file

@ -7,6 +7,10 @@ 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

@ -0,0 +1,14 @@
- if dossier.attestation.present?
#attestation-recapitulatif.default-data-block
.row.show-block.clearfix
.header
.title
.carret-right
.carret-down
ATTESTATION
.details
.left
= 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

View file

@ -1,5 +1,7 @@
= render partial: 'dossiers/edit_avis', locals: { dossier_facade: @facade }
= render partial: 'dossiers/attestation', locals: { dossier: @facade.dossier }
= render partial: 'dossiers/messagerie', locals: { dossier_facade: @facade }
= render partial: 'dossiers/motivation', locals: { dossier_facade: @facade }

View file

@ -82,6 +82,8 @@ 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

@ -15,8 +15,8 @@ describe Admin::AttestationTemplatesController, type: :controller do
before do
post :preview,
params: { procedure_id: procedure.id,
attestation_template: upload_params }
params: { procedure_id: procedure.id,
attestation_template: upload_params }
end
context 'if an attestation template does not exist on the procedure' do

View file

@ -51,4 +51,22 @@ 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