class PostgreSQLGeometricTypesTest

Attributes

connection[R]
table_name[R]

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 294
def setup
  super
  @connection = ActiveRecord::Base.connection
  @table_name = :testings
end
test_creating_column_with_box_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 327
def test_creating_column_with_box_type
  connection.create_table(table_name) do |t|
    t.box :foo_box
  end

  assert_column_exists(:foo_box)
  assert_type_correct(:foo_box, :box)
end
test_creating_column_with_circle_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 354
def test_creating_column_with_circle_type
  connection.create_table(table_name) do |t|
    t.circle :foo_circle
  end

  assert_column_exists(:foo_circle)
  assert_type_correct(:foo_circle, :circle)
end
test_creating_column_with_line_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 309
def test_creating_column_with_line_type
  connection.create_table(table_name) do |t|
    t.line :foo_line
  end

  assert_column_exists(:foo_line)
  assert_type_correct(:foo_line, :line)
end
test_creating_column_with_lseg_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 318
def test_creating_column_with_lseg_type
  connection.create_table(table_name) do |t|
    t.lseg :foo_lseg
  end

  assert_column_exists(:foo_lseg)
  assert_type_correct(:foo_lseg, :lseg)
end
test_creating_column_with_path_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 336
def test_creating_column_with_path_type
  connection.create_table(table_name) do |t|
    t.path :foo_path
  end

  assert_column_exists(:foo_path)
  assert_type_correct(:foo_path, :path)
end
test_creating_column_with_point_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 300
def test_creating_column_with_point_type
  connection.create_table(table_name) do |t|
    t.point :foo_point
  end

  assert_column_exists(:foo_point)
  assert_type_correct(:foo_point, :point)
end
test_creating_column_with_polygon_type() click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 345
def test_creating_column_with_polygon_type
  connection.create_table(table_name) do |t|
    t.polygon :foo_polygon
  end

  assert_column_exists(:foo_polygon)
  assert_type_correct(:foo_polygon, :polygon)
end

Private Instance Methods

assert_column_exists(column_name) click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 365
def assert_column_exists(column_name)
  assert connection.column_exists?(table_name, column_name)
end
assert_type_correct(column_name, type) click to toggle source
# File activerecord/test/cases/adapters/postgresql/geometric_test.rb, line 369
def assert_type_correct(column_name, type)
  column = connection.columns(table_name).find { |c| c.name == column_name.to_s }
  assert_equal type, column.type
end