Merge pull request #6341 from betagouv/revert-6333-limit-filter-size

Revert "Instructeurs : limitation de la valeur d'un filtre à 100 caractères" (#6341)
This commit is contained in:
Pierre de La Morinerie 2021-07-13 18:33:33 +02:00 committed by GitHub
commit ebf0b5ce8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 13 deletions

View file

@ -22,8 +22,6 @@ class ProcedurePresentation < ApplicationRecord
TYPE_DE_CHAMP = 'type_de_champ'
TYPE_DE_CHAMP_PRIVATE = 'type_de_champ_private'
FILTERS_VALUE_MAX_LENGTH = 100
belongs_to :assign_to, optional: false
delegate :procedure, to: :assign_to
@ -32,7 +30,6 @@ class ProcedurePresentation < ApplicationRecord
validate :check_allowed_sort_column
validate :check_allowed_sort_order
validate :check_allowed_filter_columns
validate :check_filters_max_length
def fields
fields = [
@ -285,14 +282,6 @@ class ProcedurePresentation < ApplicationRecord
end
end
def check_filters_max_length
filters.values.flatten.each do |filter|
if filter['value']&.length.to_i > FILTERS_VALUE_MAX_LENGTH
errors.add(:filters, :too_long)
end
end
end
def field_hash(label, table, column)
{
'label' => label,

View file

@ -86,7 +86,7 @@
= select_tag :field, options_for_select(@displayed_fields_options)
%br
= label_tag :value, "Valeur"
= text_field_tag :value, nil, maxlength: ProcedurePresentation::FILTERS_VALUE_MAX_LENGTH
= text_field_tag :value
= hidden_field_tag :statut, @statut
%br
= submit_tag "Ajouter le filtre", class: 'button'

View file

@ -45,7 +45,6 @@ describe ProcedurePresentation do
context 'of filters' do
it { expect(build(:procedure_presentation, filters: { "suivis" => [{ "table" => "user", "column" => "reset_password_token", "order" => "asc" }] })).to be_invalid }
it { expect(build(:procedure_presentation, filters: { "suivis" => [{ "table" => "user", "column" => "email", "value" => "A" * 200 }] })).to be_invalid }
end
end