remove now useless validation

This commit is contained in:
simon lehericey 2024-09-26 15:21:26 +02:00
parent da98aa556b
commit ba91f2f66e
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
3 changed files with 0 additions and 45 deletions

View file

@ -1,11 +1,6 @@
# frozen_string_literal: true
class ProcedurePresentation < ApplicationRecord
EXTRA_SORT_COLUMNS = {
'notifications' => ['notifications'],
'self' => ['id', 'state']
}
TABLE = 'table'
COLUMN = 'column'
ORDER = 'order'
@ -23,8 +18,6 @@ class ProcedurePresentation < ApplicationRecord
delegate :procedure, :instructeur, to: :assign_to
validate :check_allowed_displayed_fields
validate :check_allowed_sort_column
validate :check_allowed_sort_order
validate :check_allowed_filter_columns
validate :check_filters_max_length
validate :check_filters_max_integer
@ -289,17 +282,6 @@ class ProcedurePresentation < ApplicationRecord
end
end
def check_allowed_sort_column
check_allowed_field(:sort, sort, EXTRA_SORT_COLUMNS)
end
def check_allowed_sort_order
order = sort['order']
if !["asc", "desc"].include?(order)
errors.add(:sort, "#{order} nest pas une ordre permis")
end
end
def check_allowed_filter_columns
filters.each do |key, columns|
return true if key == 'migrated'

View file

@ -47,24 +47,4 @@ describe '20201001161931_migrate_filters_to_use_stable_id' do
expect(procedure_presentation_without_migration.filters['suivis']).to be_present
end
end
context 'when the procedure presentation is invalid' do
before do
procedure_presentation_with_migration.update_column(
:sort,
{ table: 'invalid-table', column: 'invalid-column', order: 'invalid-order' }
)
end
it 'removes the "migrated" key properly' do
run_task
expect(procedure_presentation_with_migration).not_to be_valid
expect(procedure_presentation_with_migration.filters).not_to have_key('migrated')
end
it 'leaves the other keys unchanged' do
run_task
expect(procedure_presentation_without_migration.filters['suivis']).to be_present
end
end
end

View file

@ -41,13 +41,6 @@ describe ProcedurePresentation do
it { expect(build(:procedure_presentation, displayed_fields: [{ table: "user", column: "reset_password_token", "order" => "asc" }])).to be_invalid }
end
context 'of sort' do
it { expect(build(:procedure_presentation, sort: { table: "notifications", column: "notifications", "order" => "asc" })).to be_valid }
it { expect(build(:procedure_presentation, sort: { table: "self", column: "id", "order" => "asc" })).to be_valid }
it { expect(build(:procedure_presentation, sort: { table: "self", column: "state", "order" => "asc" })).to be_valid }
it { expect(build(:procedure_presentation, sort: { table: "user", column: "reset_password_token", "order" => "asc" })).to be_invalid }
end
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" => "exceedingly long filter value" * 10 }] })).to be_invalid }