aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/integer_test.rb
blob: 3e45b057ff27055bff97b1ae3b364e729c021408 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require "cases/helper"
require "active_support/core_ext/numeric/bytes"

class PostgresqlIntegerTest < ActiveRecord::PostgreSQLTestCase
  class PgInteger < ActiveRecord::Base
  end

  def setup
    @connection = ActiveRecord::Base.connection

    @connection.transaction do
      @connection.create_table "pg_integers", force: true do |t|
        t.integer :quota, limit: 8, default: 2.gigabytes
      end
    end
  end

  teardown do
    @connection.drop_table "pg_integers", if_exists: true
  end

  test "schema properly respects bigint ranges" do
    assert_equal 2.gigabytes, PgInteger.new.quota
  end
end