From 886a409abf0a54349e7a97f7f5418270528bad8f Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 1 Dec 2022 13:29:08 +0100 Subject: [PATCH] fix(dossier): fix links to empty pdf templates --- app/controllers/users/commencer_controller.rb | 2 +- app/helpers/dossier_helper.rb | 4 ++++ app/views/administrateurs/procedures/show.html.haml | 2 +- app/views/commencer/show.html.haml | 3 +-- app/views/users/_procedure_footer.html.haml | 2 +- spec/controllers/users/commencer_controller_spec.rb | 6 ------ 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index 83e163844..8754f24bb 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -27,7 +27,7 @@ module Users def dossier_vide_pdf_test @procedure = retrieve_procedure_with_closed - return procedure_not_found if @procedure.blank? || (@procedure.publiee? && !@procedure.draft_changed?) + return procedure_not_found if @procedure.blank? generate_empty_pdf(@procedure.draft_revision) end diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index c51f4b5f8..f4cdd9632 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -29,6 +29,10 @@ module DossierHelper new_dossier_url(procedure_id: revision.procedure.id, brouillon: revision.draft? ? true : nil) end + def commencer_dossier_vide_for_revision_path(revision) + revision.draft? ? commencer_dossier_vide_test_path(path: revision.procedure.path) : commencer_dossier_vide_path(path: revision.procedure.path) + end + def dossier_submission_is_closed?(dossier) dossier.brouillon? && dossier.procedure.close? end diff --git a/app/views/administrateurs/procedures/show.html.haml b/app/views/administrateurs/procedures/show.html.haml index afff192c3..5c2f673b4 100644 --- a/app/views/administrateurs/procedures/show.html.haml +++ b/app/views/administrateurs/procedures/show.html.haml @@ -10,7 +10,7 @@ %span.icon.download Télécharger - = 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 + = link_to commencer_dossier_vide_for_revision_path(@procedure.active_revision), target: "_blank", rel: "noopener", class: 'button', id: "pdf-procedure" do %span.icon.printer PDF diff --git a/app/views/commencer/show.html.haml b/app/views/commencer/show.html.haml index 53f6628c7..0b755b554 100644 --- a/app/views/commencer/show.html.haml +++ b/app/views/commencer/show.html.haml @@ -41,9 +41,8 @@ = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: "fr-btn fr-btn--lg fr-btn--secondary fr-my-2w" - if @procedure.feature_enabled?(:dossier_pdf_vide) - - pdf_link = @revision.draft? ? commencer_dossier_vide_test_path(path: @procedure.path) : commencer_dossier_vide_path(path: @procedure.path) %hr %p= t('views.commencer.show.want_empty_pdf', service: @procedure&.service&.nom, adresse: @procedure&.service&.adresse) %br - = link_to t('views.commencer.show.download_empty_pdf'), pdf_link, class: "fr-btn fr-btn--lg fr-btn--secondary fr-my-2w" + = link_to t('views.commencer.show.download_empty_pdf'), commencer_dossier_vide_for_revision_path(@revision), class: "fr-btn fr-btn--lg fr-btn--secondary fr-my-2w" diff --git a/app/views/users/_procedure_footer.html.haml b/app/views/users/_procedure_footer.html.haml index fd7d40b38..4030225fe 100644 --- a/app/views/users/_procedure_footer.html.haml +++ b/app/views/users/_procedure_footer.html.haml @@ -49,7 +49,7 @@ %h3.fr-footer__top-cat= I18n.t('users.procedure_footer.dematerialisation.header') %ul.fr-footer__top-list %li - = link_to t('users.procedure_footer.dematerialisation.title_1'), commencer_dossier_vide_path(path: procedure.path), rel: 'noopener', class: 'fr-footer__top-link' + = link_to t('users.procedure_footer.dematerialisation.title_1'), commencer_dossier_vide_for_revision_path(procedure.active_revision), rel: 'noopener', class: 'fr-footer__top-link' %li = link_to t('users.procedure_footer.dematerialisation.title_2'),t('users.procedure_footer.dematerialisation.link'), rel: 'noopener', class: 'fr-footer__top-link' diff --git a/spec/controllers/users/commencer_controller_spec.rb b/spec/controllers/users/commencer_controller_spec.rb index dd0635f03..953d2fceb 100644 --- a/spec/controllers/users/commencer_controller_spec.rb +++ b/spec/controllers/users/commencer_controller_spec.rb @@ -234,11 +234,5 @@ describe Users::CommencerController, type: :controller 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