Skip to content

Commit

Permalink
add test for 9041454
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbrdo authored and tenderlove committed Jun 17, 2013
1 parent ec2b971 commit 750077a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 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 750077a

Please sign in to comment.