Skip to content
Browse files

Add test to ensure that save will raise SerializationTypeMismatch if the

serialized attribute value is not from the same class
  • Loading branch information...
1 parent a6e95c9 commit b4615ff9796da03f7d3a4c4e7d1574100f470902 @rafaelfranca rafaelfranca committed Aug 26, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 activerecord/test/cases/serialized_attribute_test.rb
View
6 activerecord/test/cases/serialized_attribute_test.rb
@@ -108,6 +108,12 @@ def test_nil_not_serialized_with_class_constraint
assert_equal 1, Topic.where(:content => nil).count
end
+ def test_serialized_attribute_should_raise_exception_on_save_with_wrong_type
+ Topic.serialize(:content, Hash)
+ topic = Topic.new(:content => "string")
+ assert_raise(ActiveRecord::SerializationTypeMismatch) { topic.save }
+ end
+
def test_should_raise_exception_on_serialized_attribute_with_type_mismatch
myobj = MyObject.new('value1', 'value2')
topic = Topic.new(:content => myobj)

0 comments on commit b4615ff

Please sign in to comment.
Something went wrong with that request. Please try again.