diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-06-12 13:30:18 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-06-12 13:50:51 -0600 |
commit | 65cd9f7694a4791b9b8515073b9b1623c0970e79 (patch) | |
tree | 5fed711b36d23ac7f056f194140cfc1f93dd1f59 /activerecord/test | |
parent | 04e727dac46a0cfbd0e5eeb419efafad39ca9f57 (diff) | |
download | rails-65cd9f7694a4791b9b8515073b9b1623c0970e79.tar.gz rails-65cd9f7694a4791b9b8515073b9b1623c0970e79.tar.bz2 rails-65cd9f7694a4791b9b8515073b9b1623c0970e79.zip |
Add a test to ensure `serialize` persists `nil` as `NULL`
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/serialized_attribute_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb index a31c3c828c..6056156698 100644 --- a/activerecord/test/cases/serialized_attribute_test.rb +++ b/activerecord/test/cases/serialized_attribute_test.rb @@ -287,4 +287,12 @@ class SerializedAttributeTest < ActiveRecord::TestCase assert_equal [topic, topic2], Topic.where(content: nil) end + + def test_nil_is_always_persisted_as_null + Topic.serialize(:content, Hash) + + topic = Topic.create!(content: { foo: "bar" }) + topic.update_attribute :content, nil + assert_equal [topic], Topic.where(content: nil) + end end |