diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-03-05 23:19:00 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-03-06 08:53:20 +0900 |
commit | 6ec2e8ac220024c6e8159c81dbe76ef8e812ed6f (patch) | |
tree | 7becec73c2a10bf0725ca93e7838e1020a2bef8b /activerecord/test/cases/adapters | |
parent | d731d6366ae68c790ef79ff66b2d2d41f5767cc3 (diff) | |
download | rails-6ec2e8ac220024c6e8159c81dbe76ef8e812ed6f.tar.gz rails-6ec2e8ac220024c6e8159c81dbe76ef8e812ed6f.tar.bz2 rails-6ec2e8ac220024c6e8159c81dbe76ef8e812ed6f.zip |
Fix `deserialize` with JSON array
Fixes #28285.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/json_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index 93558ac4d2..d4e627001c 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -16,6 +16,7 @@ module PostgresqlJSONSharedTestCases @connection.create_table("json_data_type") do |t| t.public_send column_type, "payload", default: {} # t.json 'payload', default: {} t.public_send column_type, "settings" # t.json 'settings' + t.public_send column_type, "objects", array: true # t.json 'objects', array: true end rescue ActiveRecord::StatementInvalid skip "do not test on PostgreSQL without #{column_type} type." @@ -75,6 +76,15 @@ module PostgresqlJSONSharedTestCases assert_equal({ "string" => "foo", "symbol" => "bar" }, x.reload.payload) end + def test_deserialize_with_array + x = JsonDataType.new(objects: ["foo" => "bar"]) + assert_equal ["foo" => "bar"], x.objects + x.save! + assert_equal ["foo" => "bar"], x.objects + x.reload + assert_equal ["foo" => "bar"], x.objects + end + def test_type_cast_json type = JsonDataType.type_for_attribute("payload") |