[Fix #196] Attestation: allow vizualisation after the procedure is published
This commit is contained in:
parent
671a0575ce
commit
b664709c3d
4 changed files with 28 additions and 4 deletions
|
@ -1,6 +1,16 @@
|
|||
class Admin::AttestationTemplatesController < AdminController
|
||||
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
|
||||
@attestation_template = @procedure.attestation_template || AttestationTemplate.new(procedure: @procedure)
|
||||
end
|
||||
|
|
|
@ -45,10 +45,12 @@
|
|||
.procedure-list-element{ class: ('active' if active == '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)) }
|
||||
.procedure-list-element{ class: ('active' if active == 'Attestation') }
|
||||
Attestation
|
||||
.procedure-list-element{ class: ('active' if active == 'Attestation') } Attestation
|
||||
|
||||
.split-hr-left
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ Rails.application.routes.draw do
|
|||
|
||||
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'
|
||||
patch 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
||||
|
|
|
@ -10,6 +10,18 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
|||
Timecop.freeze(Time.now)
|
||||
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
|
||||
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
||||
|
||||
|
|
Loading…
Reference in a new issue