Sha256: 4cb6c91550de767aedccdd94c131e072ff477fa53d6fdc09a1189126d2c62227

Contents?: true

Size: 762 Bytes

Versions: 4

Compression:

Stored size: 762 Bytes

Contents

require "cases/helper"

class UnsignedTypeTest < ActiveRecord::TestCase
  self.use_transactional_fixtures = false

  class UnsignedType < ActiveRecord::Base
  end

  setup do
    @connection = ActiveRecord::Base.connection
    @connection.create_table("unsigned_types", force: true) do |t|
      t.column :unsigned_integer, "int unsigned"
    end
  end

  teardown do
    @connection.drop_table "unsigned_types"
  end

  test "unsigned int max value is in range" do
    assert expected = UnsignedType.create(unsigned_integer: 4294967295)
    assert_equal expected, UnsignedType.find_by(unsigned_integer: 4294967295)
  end

  test "minus value is out of range" do
    assert_raise(RangeError) do
      UnsignedType.create(unsigned_integer: -10)
    end
  end
end

Version data entries

4 entries across 2 versions & 1 rubygems

Version Path
activejob-lock-0.0.2 rails/activerecord/test/cases/adapters/mysql/unsigned_type_test.rb
activejob-lock-0.0.2 rails/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb
activejob-lock-0.0.1 rails/activerecord/test/cases/adapters/mysql/unsigned_type_test.rb
activejob-lock-0.0.1 rails/activerecord/test/cases/adapters/mysql2/unsigned_type_test.rb