File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
activerecord/test/cases/adapters/postgresql Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ require "cases/helper"
3
+ require 'support/connection_helper'
4
+ require 'active_record/base'
5
+ require 'active_record/connection_adapters/postgresql_adapter'
6
+
7
+ class PostgresqlPointTest < ActiveRecord ::TestCase
8
+ include ConnectionHelper
9
+
10
+ class PostgresqlPoint < ActiveRecord ::Base ; end
11
+
12
+ def setup
13
+ @connection = ActiveRecord ::Base . connection
14
+ @connection . transaction do
15
+ @connection . create_table ( 'postgresql_points' ) do |t |
16
+ t . column :x , :point
17
+ end
18
+ end
19
+ end
20
+
21
+ teardown do
22
+ @connection . execute 'DROP TABLE IF EXISTS postgresql_points'
23
+ end
24
+
25
+ def test_column
26
+ column = PostgresqlPoint . columns_hash [ "x" ]
27
+ assert_equal :string , column . type
28
+ assert_equal "point" , column . sql_type
29
+ assert column . text?
30
+ assert_not column . number?
31
+ assert_not column . binary?
32
+ assert_not column . array
33
+ end
34
+
35
+ def test_roundtrip
36
+ PostgresqlPoint . create! x : [ 10 , 25.2 ]
37
+ record = PostgresqlPoint . first
38
+ assert_equal [ 10 , 25.2 ] , record . x
39
+
40
+ record . x = [ 1.1 , 2.2 ]
41
+ record . save!
42
+ assert record . reload
43
+ assert_equal [ 1.1 , 2.2 ] , record . x
44
+ end
45
+ end
You can’t perform that action at this time.
0 commit comments