Permalink
Browse files

add test for 9041454

  • Loading branch information...
1 parent 9041454 commit 89c9ff8d8b70bb5b0bc56576be94f27f87996bbe @mrbrdo mrbrdo committed Jun 5, 2013
Showing with 28 additions and 0 deletions.
  1. +28 −0 activerecord/test/cases/attribute_methods/serialization_test.rb
@@ -0,0 +1,28 @@
+require "cases/helper"
+
+module ActiveRecord
+ module AttributeMethods
+ class SerializationTest < ActiveSupport::TestCase
+ class FakeColumn < Struct.new(:name)
+ def type; :integer; end
+ def type_cast(s); "#{s}!"; end
+ end
+
+ def test_type_cast_serialized_value
+ value = stub(state: :serialized, value: "Hello world")
+ value.expects(:unserialized_value).with("Hello world!")
+
+ type = Serialization::Type.new(FakeColumn.new)
+ type.type_cast(value)
+ end
+
+ def test_type_cast_unserialized_value
+ value = stub(state: :unserialized, value: "Hello world")
+ value.expects(:unserialized_value).with()
+
+ type = Serialization::Type.new(FakeColumn.new)
+ type.type_cast(value)
+ end
+ end
+ end
+end

0 comments on commit 89c9ff8

Please sign in to comment.