Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec2b971
commit 750077a
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
activerecord/test/cases/attribute_methods/serialization_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |