From 947ef3498b49c74a79051d565b47cd4b82cb4823 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 8 Nov 2024 14:14:01 +0100 Subject: [PATCH] clean: remove old procedure_presentation methods from procedures_controller --- .../instructeurs/procedures_controller.rb | 50 ------------------- config/routes.rb | 7 --- .../procedures_controller_spec.rb | 41 --------------- 3 files changed, 98 deletions(-) diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index d110d1434..4aababff6 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -132,44 +132,6 @@ module Instructeurs @statut = 'supprime' end - # TODO: to remove because of new procedure_presentation_controller - def update_displayed_fields - ids = (params['values'].presence || []).reject(&:empty?) - - procedure_presentation.update!(displayed_columns: ids) - - redirect_back(fallback_location: instructeur_procedure_url(procedure)) - end - - # TODO: to remove because of new procedure_presentation_controller - def update_sort - procedure_presentation.update!(sorted_column_params) - - redirect_back(fallback_location: instructeur_procedure_url(procedure)) - end - - # TODO: to remove because of new procedure_presentation_controller - def add_filter - if !procedure_presentation.update(filter_params) - # complicated way to display inner error messages - flash.alert = procedure_presentation.errors - .flat_map { _1.detail[:value].flat_map { |c| c.errors.full_messages } } - end - - redirect_back(fallback_location: instructeur_procedure_url(procedure)) - end - - # TODO: to remove because of new procedure_presentation_controller - def update_filter - @statut = statut - @procedure = procedure - @procedure_presentation = procedure_presentation - current_filter = procedure_presentation.filters_name_for(@statut) - # According to the html, the selected column is the last one - h_id = JSON.parse(params[current_filter].last[:id], symbolize_names: true) - @column = procedure.find_column(h_id:) - end - def download_export groupe_instructeurs = current_instructeur .groupe_instructeurs @@ -410,17 +372,5 @@ module Instructeurs def cookies_export_key "exports_#{@procedure.id}_seen_at" end - - # TODO: to remove because of new procedure_presentation_controller - def sorted_column_params - params.permit(sorted_column: [:order, :id]) - end - - # TODO: to remove because of new procedure_presentation_controller - def filter_params - keys = [:tous_filters, :a_suivre_filters, :suivis_filters, :traites_filters, :expirant_filters, :archives_filters, :supprimes_filters] - h = keys.index_with { [:id, :filter] } - params.permit(h) - end end end diff --git a/config/routes.rb b/config/routes.rb index 4ecc68874..518f513aa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -490,13 +490,6 @@ Rails.application.routes.draw do end end - # TODO: to remove because of new procedure_presentation_controller - patch 'update_displayed_fields' - get 'update_sort' => 'procedures#update_sort', as: 'update_sort' - post 'add_filter' - post 'update_filter' - get 'remove_filter' - get 'download_export' post 'download_export' get 'polling_last_export' diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index 8fcd18be9..d759412f9 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -905,45 +905,4 @@ describe Instructeurs::ProceduresController, type: :controller do it { is_expected.to have_http_status(:forbidden) } end end - - describe '#update_filter' do - let(:instructeur) { create(:instructeur) } - let(:procedure) { create(:procedure, :for_individual) } - def procedure_presentation = instructeur.assign_to.first.procedure_presentation_or_default_and_errors.first - - before do - create(:assign_to, instructeur:, groupe_instructeur: build(:groupe_instructeur, procedure:)) - - sign_in(instructeur.user) - end - - it 'can change order' do - column = procedure.find_column(label: "Nom") - expect { get :update_sort, params: { procedure_id: procedure.id, sorted_column: { id: column.id, order: 'asc' } } } - .to change { procedure_presentation.sorted_column } - .from(procedure.default_sorted_column) - .to(SortedColumn.new(column:, order: 'asc')) - end - end - - describe '#add_filter' do - let(:instructeur) { create(:instructeur) } - let(:procedure) { create(:procedure, :for_individual) } - - before do - create(:assign_to, instructeur:, groupe_instructeur: build(:groupe_instructeur, procedure:)) - - sign_in(instructeur.user) - end - - subject do - column = procedure.find_column(label: "Nom") - post :add_filter, params: { procedure_id: procedure.id, a_suivre_filters: [{ id: column.id, filter: "n" * 4049 }] } - end - - it 'should render the error' do - subject - expect(flash.alert[0]).to include("Le filtre « Nom » est trop long (maximum: 4048 caractères)") - end - end end