[#2622] Change sort to proper JSONB
This commit is contained in:
parent
68608307ad
commit
1419e9b73f
6 changed files with 6 additions and 9 deletions
|
@ -132,7 +132,7 @@ module NewGestionnaire
|
|||
'table' => table,
|
||||
'column' => column,
|
||||
'order' => order
|
||||
}.to_json
|
||||
}
|
||||
|
||||
procedure_presentation.update(sort: sort)
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ class Procedure < ApplicationRecord
|
|||
'table' => 'self',
|
||||
'column' => 'id',
|
||||
'order' => 'desc'
|
||||
}.to_json
|
||||
}
|
||||
end
|
||||
|
||||
def whitelist!
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
class ProcedurePresentation < ApplicationRecord
|
||||
belongs_to :assign_to
|
||||
|
||||
def sort
|
||||
JSON.parse(read_attribute(:sort))
|
||||
end
|
||||
|
||||
def filters
|
||||
JSON.parse(read_attribute(:filters))
|
||||
end
|
||||
|
|
|
@ -2,7 +2,8 @@ namespace :'2018_09_20_procedure_presentation_jsonb' do
|
|||
task run: :environment do
|
||||
ProcedurePresentation.update_all(
|
||||
<<~SQL
|
||||
displayed_fields = ('[' || ARRAY_TO_STRING(old_displayed_fields, ',') || ']')::JSONB
|
||||
displayed_fields = ('[' || ARRAY_TO_STRING(old_displayed_fields, ',') || ']')::JSONB,
|
||||
sort = (sort #>> '{}')::jsonb
|
||||
SQL
|
||||
)
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ describe ProcedurePresentation do
|
|||
{ "label" => "test1", "table" => "user" },
|
||||
{ "label" => "test2", "table" => "champs" }
|
||||
],
|
||||
sort: { "table" => "user","column" => "email","order" => "asc" }.to_json,
|
||||
sort: { "table" => "user","column" => "email","order" => "asc" },
|
||||
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "table1", "column" => "column1" }] }.to_json
|
||||
).id
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ describe Procedure do
|
|||
end
|
||||
|
||||
describe ".default_sort" do
|
||||
it { expect(Procedure.default_sort).to eq("{\"table\":\"self\",\"column\":\"id\",\"order\":\"desc\"}") }
|
||||
it { expect(Procedure.default_sort).to eq({ "table" => "self", "column" => "id", "order" => "desc" }) }
|
||||
end
|
||||
|
||||
describe "#export_filename" do
|
||||
|
|
Loading…
Reference in a new issue