From b117bc9774abfe2556875d3cda6ad83b6e6bafd4 Mon Sep 17 00:00:00 2001 From: mfo Date: Tue, 24 Sep 2024 18:06:59 +0200 Subject: [PATCH] fix(export_template#preview): avoid 414 responses, using get method is not a good option for procedure with a lot of types_de_champ, otherwise we reach http get size limit --- .../instructeurs/export_templates/_form.html.haml | 2 +- config/routes.rb | 2 +- .../export_templates_controller_spec.rb | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/instructeurs/export_templates/_form.html.haml b/app/views/instructeurs/export_templates/_form.html.haml index 3f022902b..a8d9e8c64 100644 --- a/app/views/instructeurs/export_templates/_form.html.haml +++ b/app/views/instructeurs/export_templates/_form.html.haml @@ -11,7 +11,7 @@ .fr-grid-row.fr-grid-row--gutters .fr-col-12.fr-col-md-8.fr-pr-4w - = form_with model: [:instructeur, procedure, export_template], data: { turbo: 'true', controller: 'autosubmit' } do |f| + = form_with model: [:instructeur, procedure, export_template], data: { turbo: 'true', controller: 'autosubmit', method: :put } do |f| %input.hidden{ type: 'submit', formaction: preview_instructeur_procedure_export_templates_path, data: { autosubmit_target: 'submitter' }, formnovalidate: 'true', formmethod: 'get' } = f.hidden_field :kind, value: 'zip' diff --git a/config/routes.rb b/config/routes.rb index 86b1ef45a..82bac9ef8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -455,7 +455,7 @@ Rails.application.routes.draw do resources :procedures, only: [] do resources :export_templates, only: [:new, :create, :edit, :update, :destroy] do collection do - get 'preview' + put 'preview' end end end diff --git a/spec/controllers/instructeurs/export_templates_controller_spec.rb b/spec/controllers/instructeurs/export_templates_controller_spec.rb index 3e2bc4737..4576090fc 100644 --- a/spec/controllers/instructeurs/export_templates_controller_spec.rb +++ b/spec/controllers/instructeurs/export_templates_controller_spec.rb @@ -166,13 +166,15 @@ describe Instructeurs::ExportTemplatesController, type: :controller do let(:export_template) { create(:export_template, groupe_instructeur:) } - subject { get :preview, params: { procedure_id: procedure.id, id: export_template.id, export_template: export_template_params }, format: :turbo_stream } + context 'with put request' do + subject { put :preview, params: { procedure_id: procedure.id, id: export_template.id, export_template: export_template_params }, format: :turbo_stream } - it '' do - dossier = create(:dossier, procedure: procedure, for_procedure_preview: true) - subject - expect(response.body).to include "DOSSIER_#{dossier.id}" - expect(response.body).to include "mon_export_#{dossier.id}.pdf" + it 'works with bigbig procedure' do + dossier = create(:dossier, procedure: procedure, for_procedure_preview: true) + subject + expect(response.body).to include "DOSSIER_#{dossier.id}" + expect(response.body).to include "mon_export_#{dossier.id}.pdf" + end end end