Sha256: 54536ce49cbd3601e8eea314d17b57dcbcd398e7db60a1a198a5438ee92c6f69

Contents?: true

Size: 860 Bytes

Versions: 10

Compression:

Stored size: 860 Bytes

Contents

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

      class NullCoder
        def load(v); v; end
      end

      def test_type_cast_serialized_value
        value = Serialization::Attribute.new(NullCoder.new, "Hello world", :serialized)
        type = Serialization::Type.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_cast(value)
        assert_equal "Hello world", type.type_cast(value)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ibm_db-3.0.4-x86-mingw32 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.4 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.3-x86-mingw32 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.3 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.2-x86-mingw32 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.2 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.1 test/cases/attribute_methods/serialization_test.rb
ibm_db-3.0.1-x86-mingw32 test/cases/attribute_methods/serialization_test.rb
activerecord-nuodb-adapter-1.1 test/cases/attribute_methods/serialization_test.rb
activerecord-nuodb-adapter-1.0.4 test/cases/attribute_methods/serialization_test.rb