diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index f75a04ed5..1185a416f 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -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} n’est pas une ordre permis") - end - end - def check_allowed_filter_columns filters.each do |key, columns| return true if key == 'migrated' diff --git a/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb b/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb index 866c5fe55..1eb4e20d5 100644 --- a/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb +++ b/spec/lib/tasks/deployment/20210720133539_remove_migration_status_on_filters_spec.rb @@ -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 diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index a7677d4f7..8fb60d672 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -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 }