From 2eb547a4d9cfb4ed1c92397921402048162f5fc8 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Wed, 28 May 2014 08:24:59 -0700 Subject: Refactor serialized types to be partially defined as custom properties Many of the methods defined in `AttributeMethods::Serialization` can be refactored onto this type as well, but this is a reasonable small step. Removes the `Type` class, and the need for `decorate_columns` to handle serialized types. --- .../test/cases/attribute_methods/serialization_test.rb | 4 ++-- activerecord/test/cases/serialized_attribute_test.rb | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/attribute_methods/serialization_test.rb b/activerecord/test/cases/attribute_methods/serialization_test.rb index 75de773961..2e3bcadab1 100644 --- a/activerecord/test/cases/attribute_methods/serialization_test.rb +++ b/activerecord/test/cases/attribute_methods/serialization_test.rb @@ -14,13 +14,13 @@ module ActiveRecord def test_type_cast_serialized_value value = Serialization::Attribute.new(NullCoder.new, "Hello world", :serialized) - type = Serialization::Type.new(FakeColumn.new) + type = Type::Serialized.new(FakeColumn.new) assert_equal "Hello world!", type.type_cast(value) end def test_type_cast_unserialized_value value = Serialization::Attribute.new(nil, "Hello world", :unserialized) - type = Serialization::Type.new(FakeColumn.new) + type = Type::Serialized.new(FakeColumn.new) type.type_cast(value) assert_equal "Hello world", type.type_cast(value) end diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb index c8f9d7cf87..c65a86a6ef 100644 --- a/activerecord/test/cases/serialized_attribute_test.rb +++ b/activerecord/test/cases/serialized_attribute_test.rb @@ -235,16 +235,6 @@ class SerializedAttributeTest < ActiveRecord::TestCase assert_equal [], light.long_state end - def test_serialized_column_should_not_be_wrapped_twice - Topic.serialize(:content, MyObject) - - myobj = MyObject.new('value1', 'value2') - Topic.create(content: myobj) - Topic.create(content: myobj) - type = Topic.column_types["content"] - assert !type.instance_variable_get("@column").is_a?(ActiveRecord::AttributeMethods::Serialization::Type) - end - def test_serialized_column_should_unserialize_after_update_column t = Topic.create(content: "first") assert_equal("first", t.content) -- cgit v1.2.3