diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 11:41:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-01 14:25:47 -0800 |
commit | ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476 (patch) | |
tree | 690ba63f9d71107e6e54c790e9742f093d34e7be /activerecord/test | |
parent | ee34b4cf346975d0aef7f26ef47ee2e4f3e13c37 (diff) | |
download | rails-ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476.tar.gz rails-ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476.tar.bz2 rails-ebe485fd8ec80a1a9b86516bc6f74bc5bbba3476.zip |
serialize can take an arbitrary code object
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index a58d5dec81..7c677d55ca 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1018,6 +1018,27 @@ class BasicsTest < ActiveRecord::TestCase assert_equal topic.content, false end + def test_serialize_with_coder + coder = Class.new { + # Identity + def load(thing) + thing + end + + # base 64 + def dump(thing) + [thing].pack('m') + end + }.new + + Topic.serialize(:content, coder) + s = 'hello world' + topic = Topic.new(:content => s) + assert topic.save + topic = topic.reload + assert_equal [s].pack('m'), topic.content + end + def test_quote author_name = "\\ \001 ' \n \\n \"" topic = Topic.create('author_name' => author_name) |