aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-21 11:47:11 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-21 11:48:32 -0700
commite8460f8bbe73537897f2162d1cccda943d8c0f4a (patch)
treedc6eb6b07f4848d4b93d8dc1798a92e31ac3a24e /activerecord/test/cases/adapters
parent14599a575850567b28967decffbbbb270fa92676 (diff)
downloadrails-e8460f8bbe73537897f2162d1cccda943d8c0f4a.tar.gz
rails-e8460f8bbe73537897f2162d1cccda943d8c0f4a.tar.bz2
rails-e8460f8bbe73537897f2162d1cccda943d8c0f4a.zip
Don't error when invalid json is assigned to a JSON column
Keeping with our behavior elsewhere in the system, invalid input is assumed to be `nil`. Fixes #18629.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r--activerecord/test/cases/adapters/postgresql/json_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb
index 5f6cda1986..f5ae872483 100644
--- a/activerecord/test/cases/adapters/postgresql/json_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/json_test.rb
@@ -179,6 +179,14 @@ module PostgresqlJSONSharedTestCases
assert_equal({ 'one' => 'two', 'three' => 'four' }, json.payload)
assert_not json.changed?
end
+
+ def test_assigning_invalid_json
+ json = JsonDataType.new
+
+ json.payload = 'foo'
+
+ assert_nil json.payload
+ end
end
class PostgresqlJSONTest < ActiveRecord::TestCase