aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/serialized_attribute_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/serialized_attribute_test.rb')
-rw-r--r--activerecord/test/cases/serialized_attribute_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb
index 5609cf310c..c8f9d7cf87 100644
--- a/activerecord/test/cases/serialized_attribute_test.rb
+++ b/activerecord/test/cases/serialized_attribute_test.rb
@@ -244,4 +244,20 @@ class SerializedAttributeTest < ActiveRecord::TestCase
type = Topic.column_types["content"]
assert !type.instance_variable_get("@column").is_a?(ActiveRecord::AttributeMethods::Serialization::Type)
end
+
+ def test_serialized_column_should_unserialize_after_update_column
+ t = Topic.create(content: "first")
+ assert_equal("first", t.content)
+
+ t.update_column(:content, Topic.serialized_attributes["content"].dump("second"))
+ assert_equal("second", t.content)
+ end
+
+ def test_serialized_column_should_unserialize_after_update_attribute
+ t = Topic.create(content: "first")
+ assert_equal("first", t.content)
+
+ t.update_attribute(:content, "second")
+ assert_equal("second", t.content)
+ end
end