aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-23 09:38:48 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-23 09:40:01 -0700
commite35221cfd948098c6fabdff5fed3877edb8921d3 (patch)
treea929aae400a645ed8bb94e2bfd00d5493f33c326 /activerecord/test
parentd26704a15f88d384dd282425daa832affdb5f8c1 (diff)
downloadrails-e35221cfd948098c6fabdff5fed3877edb8921d3.tar.gz
rails-e35221cfd948098c6fabdff5fed3877edb8921d3.tar.bz2
rails-e35221cfd948098c6fabdff5fed3877edb8921d3.zip
Don't treat `nil` as changed in serialized types
We were ignoring the `default_value?` escape clause in the serialized type, which caused the default value to always be treated as changed. Fixes #18169
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/serialized_attribute_test.rb8
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 56a0e92e1d..c8441201ca 100644
--- a/activerecord/test/cases/serialized_attribute_test.rb
+++ b/activerecord/test/cases/serialized_attribute_test.rb
@@ -256,4 +256,12 @@ class SerializedAttributeTest < ActiveRecord::TestCase
assert_equal("second", t.content)
assert_equal("second", t.reload.content)
end
+
+ def test_nil_is_not_changed_when_serialized_with_a_class
+ Topic.serialize(:content, Array)
+
+ topic = Topic.new(content: nil)
+
+ assert_not topic.content_changed?
+ end
end