[Fix #196] Attestation: allow vizualisation after the procedure is published

This commit is contained in:
Simon Lehericey 2017-06-09 15:26:52 +02:00
parent 671a0575ce
commit b664709c3d
4 changed files with 28 additions and 4 deletions

View file

@ -1,6 +1,16 @@
class Admin::AttestationTemplatesController < AdminController class Admin::AttestationTemplatesController < AdminController
before_action :retrieve_procedure before_action :retrieve_procedure
def show
attestation_template = @procedure.attestation_template
@logo = attestation_template.logo
@title = attestation_template.title
@body = attestation_template.body
@signature = attestation_template.signature
@footer = attestation_template.footer
@created_at = DateTime.now
end
def edit def edit
@attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure) @attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure)
end end

View file

@ -45,10 +45,12 @@
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') } .procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
Prévisualisation Prévisualisation
- unless @procedure.locked? - if @procedure.locked?
%a#onglet-attestation{ href: url_for(admin_procedure_attestation_template_path(@procedure, format: :pdf)), target: '_blank' }
.procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
- else
%a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) } %a#onglet-attestation{ href: url_for(edit_admin_procedure_attestation_template_path(@procedure)) }
.procedure-list-element{ class: ('active' if active == 'Attestation') } .procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
Attestation
.split-hr-left .split-hr-left

View file

@ -146,7 +146,7 @@ Rails.application.routes.draw do
resource :previsualisation, only: [:show] resource :previsualisation, only: [:show]
resource :attestation_template, only: [:edit, :update, :create] resource :attestation_template, only: [:show, :edit, :update, :create]
post 'attestation_template/disactivate' => 'attestation_templates#disactivate' post 'attestation_template/disactivate' => 'attestation_templates#disactivate'
patch 'attestation_template/disactivate' => 'attestation_templates#disactivate' patch 'attestation_template/disactivate' => 'attestation_templates#disactivate'

View file

@ -10,6 +10,18 @@ describe Admin::AttestationTemplatesController, type: :controller do
Timecop.freeze(Time.now) Timecop.freeze(Time.now)
end end
describe 'GET #show' do
before { get :show, params: { procedure_id: procedure.id, format: :pdf } }
it { expect(subject.status).to eq(200) }
it { expect(assigns[:title]).to eq(attestation_template.title) }
it { expect(assigns[:logo].read).to eq(attestation_template.logo.read) }
it { expect(assigns[:body]).to eq(attestation_template.body) }
it { expect(assigns[:signature].read).to eq(attestation_template.signature.read) }
it { expect(assigns[:footer]).to eq(attestation_template.footer) }
it { expect(assigns[:created_at]).to eq(DateTime.now) }
end
describe 'POST #preview' do describe 'POST #preview' do
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } } let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }