diff options
author | Severin Schoepke <severin.schoepke@gmail.com> | 2013-10-25 14:45:52 +0200 |
---|---|---|
committer | Severin Schoepke <severin.schoepke@gmail.com> | 2013-10-25 17:05:42 +0200 |
commit | c3606afb2a54ac11e31360cf1dbe13fbdf893f73 (patch) | |
tree | 8296d1af679f6f331531ca46b204c415ab94019c /activerecord/test | |
parent | 3c3ffac0117a9a3ce4de1f84a7a3eb7a35d016a8 (diff) | |
download | rails-c3606afb2a54ac11e31360cf1dbe13fbdf893f73.tar.gz rails-c3606afb2a54ac11e31360cf1dbe13fbdf893f73.tar.bz2 rails-c3606afb2a54ac11e31360cf1dbe13fbdf893f73.zip |
cast json values on write to be consistent with reading from the db.
See also commit 5ac2341fab689344991b2a4817bd2bc8b3edac9d
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/json_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index f7609404ce..c33c7ef968 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -49,6 +49,13 @@ class PostgresqlJSONTest < ActiveRecord::TestCase JsonDataType.reset_column_information end + def test_cast_value_on_write + x = JsonDataType.new payload: {"string" => "foo", :symbol => :bar} + assert_equal({"string" => "foo", "symbol" => "bar"}, x.payload) + x.save + assert_equal({"string" => "foo", "symbol" => "bar"}, x.reload.payload) + end + def test_type_cast_json assert @column |