diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-26 03:09:31 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-26 03:56:19 -0300 |
commit | b4615ff9796da03f7d3a4c4e7d1574100f470902 (patch) | |
tree | 77ae53c51fdb8a122d5f5e3f054f37691bbf1add /activerecord | |
parent | a6e95c93ca60aa385bdcfe4e8e3d0f61a37efaed (diff) | |
download | rails-b4615ff9796da03f7d3a4c4e7d1574100f470902.tar.gz rails-b4615ff9796da03f7d3a4c4e7d1574100f470902.tar.bz2 rails-b4615ff9796da03f7d3a4c4e7d1574100f470902.zip |
Add test to ensure that save will raise SerializationTypeMismatch if the
serialized attribute value is not from the same class
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/serialized_attribute_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb index 64319b999d..f24ee54cd2 100644 --- a/activerecord/test/cases/serialized_attribute_test.rb +++ b/activerecord/test/cases/serialized_attribute_test.rb @@ -108,6 +108,12 @@ class SerializedAttributeTest < ActiveRecord::TestCase 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) |