aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/json_test.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-10-25 08:17:40 -0700
committerYves Senn <yves.senn@gmail.com>2013-10-25 08:17:40 -0700
commitdc8fac1cacb120dc2535b67bdd6436d220901c7a (patch)
tree0949275d6b2bc9827ab9a35b88575cbb423f8456 /activerecord/test/cases/adapters/postgresql/json_test.rb
parent0e918ea97acc71e23e7a43963a5147d0ad8a994d (diff)
parentc3606afb2a54ac11e31360cf1dbe13fbdf893f73 (diff)
downloadrails-dc8fac1cacb120dc2535b67bdd6436d220901c7a.tar.gz
rails-dc8fac1cacb120dc2535b67bdd6436d220901c7a.tar.bz2
rails-dc8fac1cacb120dc2535b67bdd6436d220901c7a.zip
Merge pull request #12643 from severin/pg_cast_json_on_write
cast json values on write to be consistent with reading from the db.
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/json_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/json_test.rb7
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