Sha256: 910de9121f76c6e31a57872b424ce1c4ae1ac399f802d76c3ebd6edc56c6a448

Contents?: true

Size: 702 Bytes

Versions: 6

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

require "cases/helper"
require "ipaddr"

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter < AbstractAdapter
      class CidrTest < ActiveRecord::PostgreSQLTestCase
        test "type casting IPAddr for database" do
          type = OID::Cidr.new
          ip = IPAddr.new("255.0.0.0/8")
          ip2 = IPAddr.new("127.0.0.1")

          assert_equal "255.0.0.0/8", type.serialize(ip)
          assert_equal "127.0.0.1/32", type.serialize(ip2)
        end

        test "casting does nothing with non-IPAddr objects" do
          type = OID::Cidr.new

          assert_equal "foo", type.serialize("foo")
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ibm_db-5.5.0 test/cases/adapters/postgresql/cidr_test.rb
ibm_db-5.4.1 test/cases/adapters/postgresql/cidr_test.rb
ibm_db-5.4.0 test/cases/adapters/postgresql/cidr_test.rb
ibm_db-5.3.2 test/cases/adapters/postgresql/cidr_test.rb
ibm_db-5.3.1 test/cases/adapters/postgresql/cidr_test.rb
ruby-on-quails-0.1.0 activerecord/test/cases/adapters/postgresql/cidr_test.rb