diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-06-02 13:21:12 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-06-02 13:21:12 +0200 |
commit | d7ba8b70183a22cc505fe1735c2c2ca3e1c0f174 (patch) | |
tree | 6a9fc90140a1500f00484daa9fbc7b45235b3355 /activerecord/test/cases/adapters/postgresql | |
parent | f17fa8ef6f2abffeea5398cc450172c0975cad27 (diff) | |
download | rails-d7ba8b70183a22cc505fe1735c2c2ca3e1c0f174.tar.gz rails-d7ba8b70183a22cc505fe1735c2c2ca3e1c0f174.tar.bz2 rails-d7ba8b70183a22cc505fe1735c2c2ca3e1c0f174.zip |
test pg, add basic test cases for point datatype.
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/geometric_test.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/geometric_test.rb b/activerecord/test/cases/adapters/postgresql/geometric_test.rb new file mode 100644 index 0000000000..775b1d2d69 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/geometric_test.rb @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +require "cases/helper" +require 'support/connection_helper' +require 'active_record/base' +require 'active_record/connection_adapters/postgresql_adapter' + +class PostgresqlPointTest < ActiveRecord::TestCase + include ConnectionHelper + + class PostgresqlPoint < ActiveRecord::Base; end + + def setup + @connection = ActiveRecord::Base.connection + @connection.transaction do + @connection.create_table('postgresql_points') do |t| + t.column :x, :point + end + end + end + + teardown do + @connection.execute 'DROP TABLE IF EXISTS postgresql_points' + end + + def test_column + column = PostgresqlPoint.columns_hash["x"] + assert_equal :string, column.type + assert_equal "point", column.sql_type + assert column.text? + assert_not column.number? + assert_not column.binary? + assert_not column.array + end + + def test_roundtrip + PostgresqlPoint.create! x: [10, 25.2] + record = PostgresqlPoint.first + assert_equal [10, 25.2], record.x + + record.x = [1.1, 2.2] + record.save! + assert record.reload + assert_equal [1.1, 2.2], record.x + end +end |