diff options
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/geometric_test.rb')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/geometric_test.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/geometric_test.rb b/activerecord/test/cases/adapters/postgresql/geometric_test.rb index 775b1d2d69..89a72f08b4 100644 --- a/activerecord/test/cases/adapters/postgresql/geometric_test.rb +++ b/activerecord/test/cases/adapters/postgresql/geometric_test.rb @@ -1,11 +1,13 @@ # -*- coding: utf-8 -*- require "cases/helper" require 'support/connection_helper' +require 'support/schema_dumping_helper' require 'active_record/base' require 'active_record/connection_adapters/postgresql_adapter' class PostgresqlPointTest < ActiveRecord::TestCase include ConnectionHelper + include SchemaDumpingHelper class PostgresqlPoint < ActiveRecord::Base; end @@ -14,6 +16,8 @@ class PostgresqlPointTest < ActiveRecord::TestCase @connection.transaction do @connection.create_table('postgresql_points') do |t| t.column :x, :point + t.column :y, :point, default: [12.2, 13.3] + t.column :z, :point, default: "(14.4,15.5)" end end end @@ -32,6 +36,23 @@ class PostgresqlPointTest < ActiveRecord::TestCase assert_not column.array end + def test_default + column = PostgresqlPoint.columns_hash["y"] + assert_equal [12.2, 13.3], column.default + assert_equal [12.2, 13.3], PostgresqlPoint.new.y + + column = PostgresqlPoint.columns_hash["z"] + assert_equal [14.4, 15.5], column.default + assert_equal [14.4, 15.5], PostgresqlPoint.new.z + end + + def test_schema_dumping + output = dump_table_schema("postgresql_points") + assert_match %r{t\.string\s+"x"$}, output + assert_match %r{t\.string\s+"y",\s+default: \[12\.2, 13\.3\]$}, output + assert_match %r{t\.string\s+"z",\s+default: \[14\.4, 15\.5\]$}, output + end + def test_roundtrip PostgresqlPoint.create! x: [10, 25.2] record = PostgresqlPoint.first |