aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Berdajs <mrbrdo@gmail.com>2013-06-05 19:53:17 +0200
committerJan Berdajs <mrbrdo@gmail.com>2013-06-05 19:53:17 +0200
commit89c9ff8d8b70bb5b0bc56576be94f27f87996bbe (patch)
tree4ca7112b71f51efc4057315ef59a364d4779da86
parent9041454def79d8e61cabe49e7c5cb72cef29138b (diff)
downloadrails-89c9ff8d8b70bb5b0bc56576be94f27f87996bbe.tar.gz
rails-89c9ff8d8b70bb5b0bc56576be94f27f87996bbe.tar.bz2
rails-89c9ff8d8b70bb5b0bc56576be94f27f87996bbe.zip
add test for 9041454def79d8e61cabe49e7c5cb72cef29138b
-rw-r--r--activerecord/test/cases/attribute_methods/serialization_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods/serialization_test.rb b/activerecord/test/cases/attribute_methods/serialization_test.rb
new file mode 100644
index 0000000000..8ce6192096
--- /dev/null
+++ b/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