mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 03:18:23 +00:00
FIX: Allow Time objects to be deserialized in PostRevision (stable) (#17502)
Followup to bb287c6c74aed9c9ccd36f6270c219f806bb84f3
This commit is contained in:
parent
c75ec7335d
commit
5d2ecce3f6
@ -246,7 +246,7 @@ module Discourse
|
||||
# see: http://stackoverflow.com/questions/11894180/how-does-one-correctly-add-custom-sql-dml-in-migrations/11894420#11894420
|
||||
config.active_record.schema_format = :sql
|
||||
|
||||
config.active_record.yaml_column_permitted_classes = [Hash, HashWithIndifferentAccess]
|
||||
config.active_record.yaml_column_permitted_classes = [Hash, HashWithIndifferentAccess, Time]
|
||||
|
||||
# We use this in development-mode only (see development.rb)
|
||||
config.active_record.use_schema_cache_dump = false
|
||||
|
26
spec/models/post_revision_spec.rb
Normal file
26
spec/models/post_revision_spec.rb
Normal file
@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe PostRevision do
|
||||
it "can deserialize old YAML" do
|
||||
# Date objects are stored in core post_revisions prior
|
||||
# to https://github.com/discourse/discourse/commit/e7f251c105
|
||||
# and are also stored by some plugins
|
||||
|
||||
pr = Fabricate(:post_revision)
|
||||
DB.exec("UPDATE post_revisions SET modifications = ?", <<~YAML)
|
||||
---
|
||||
last_version_at:
|
||||
- 2013-12-12 21:40:13.225239000 Z
|
||||
- 2013-12-12 22:10:51.433689320 Z
|
||||
YAML
|
||||
pr.reload
|
||||
expect(pr.modifications).to eq(
|
||||
{
|
||||
"last_version_at" => [
|
||||
Time.parse("2013-12-12 21:40:13.225239000 Z"),
|
||||
Time.parse("2013-12-12 22:10:51.433689320 Z")
|
||||
]
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user