Merge pull request #7188 from betagouv/7131/rgpd/print-empty-form

feat(adminstrateurs#dossier_vide): add button to /dossier_vide so administrateur can have a pdf version of their form to send it in regards to RGPD
This commit is contained in:
mfo 2022-04-25 15:07:53 +02:00 committed by GitHub
commit 937b9c5b0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 1 deletions

View file

@ -4,6 +4,10 @@
metadatas: ["Créée le #{@procedure.created_at.strftime('%d/%m/%Y')} - n° #{@procedure.id}", "#{@procedure.close? ? "Close le #{@procedure.closed_at.strftime('%d/%m/%Y')}" : @procedure.locked? ? "Publiée - #{procedure_lien(@procedure)}" : "Brouillon"}"] }
.container.procedure-admin-container
= link_to @procedure.active_revision.draft? ? commencer_dossier_vide_test_path(path: @procedure.path) : commencer_dossier_vide_path(path: @procedure.path), target: "_blank", rel: "noopener", class: 'button', id: "pdf-procedure" do
%span.icon.printer
PDF
= link_to apercu_admin_procedure_path(@procedure), target: "_blank", rel: "noopener", class: 'button', id: "preview-procedure" do
%span.icon.preview
Prévisualiser

View file

@ -246,7 +246,7 @@ Rails.application.routes.draw do
end
namespace :commencer do
get '/test/:path/dossier_vide', action: 'dossier_vide_pdf_test', as: :dossier_vide_test
get '/test/:path/dossier_vide', action: :dossier_vide_pdf_test, as: :dossier_vide_test
get '/test/:path', action: 'commencer_test', as: :test
get '/:path', action: 'commencer'
get '/:path/dossier_vide', action: 'dossier_vide_pdf', as: :dossier_vide

View file

@ -160,4 +160,41 @@ describe Users::CommencerController, type: :controller do
end
end
end
describe '#dossier_vide_pdf' do
before { get :dossier_vide_pdf, params: { path: procedure.path } }
context 'published procedure' do
let(:procedure) { create(:procedure, :published, :with_service, :with_path) }
it 'works' do
expect(response).to have_http_status(:success)
end
end
context 'not published procedure' do
let(:procedure) { create(:procedure, :with_service, :with_path) }
it 'redirects to procedure not found' do
expect(response).to have_http_status(302)
end
end
end
describe '#dossier_vide_test_pdf' do
before { get :dossier_vide_pdf_test, params: { path: procedure.path } }
context 'not published procedure' do
let(:procedure) { create(:procedure, :with_service, :with_path) }
it 'works' do
expect(response).to have_http_status(:success)
end
end
context 'published procedure' do
let(:procedure) { create(:procedure, :published, :with_service, :with_path) }
it 'redirect to procedure not found' do
expect(response).to have_http_status(302)
end
end
end
end