@@ -13,22 +13,22 @@ def test_version
13
13
end
14
14
15
15
def test_postgis_available
16
- assert_equal "PostGIS" , SpatialModel . connection . adapter_name
17
- assert_equal postgis_version , SpatialModel . connection . postgis_lib_version
18
- valid_version = [ "2." , "3." ] . any? { |major_ver | SpatialModel . connection . postgis_lib_version . start_with? major_ver }
16
+ assert_equal "PostGIS" , SpatialModel . lease_connection . adapter_name
17
+ assert_equal SpatialModel . lease_connection . select_value ( "SELECT postgis_lib_version()" ) , SpatialModel . lease_connection . postgis_lib_version
18
+ valid_version = [ "2." , "3." ] . any? { |major_ver | SpatialModel . lease_connection . postgis_lib_version . start_with? major_ver }
19
19
assert valid_version
20
20
end
21
21
22
22
def test_arel_visitor
23
- visitor = Arel ::Visitors ::PostGIS . new ( SpatialModel . connection )
23
+ visitor = Arel ::Visitors ::PostGIS . new ( SpatialModel . lease_connection )
24
24
node = RGeo ::ActiveRecord ::SpatialConstantNode . new ( "POINT (1.0 2.0)" )
25
25
collector = Arel ::Collectors ::PlainString . new
26
26
visitor . accept ( node , collector )
27
27
assert_equal "ST_GeomFromText('POINT (1.0 2.0)')" , collector . value
28
28
end
29
29
30
30
def test_arel_visitor_will_not_visit_string
31
- visitor = Arel ::Visitors ::PostGIS . new ( SpatialModel . connection )
31
+ visitor = Arel ::Visitors ::PostGIS . new ( SpatialModel . lease_connection )
32
32
node = "POINT (1 2)"
33
33
collector = Arel ::Collectors ::PlainString . new
34
34
@@ -111,7 +111,7 @@ def test_default_value
111
111
112
112
def test_custom_factory
113
113
klass = SpatialModel
114
- klass . connection . create_table ( :spatial_models , force : true ) do |t |
114
+ klass . lease_connection . create_table ( :spatial_models , force : true ) do |t |
115
115
t . st_polygon ( :area , srid : 4326 )
116
116
end
117
117
klass . reset_column_information
@@ -127,7 +127,7 @@ def test_custom_factory
127
127
128
128
def test_spatial_factory_attrs_parsing
129
129
klass = SpatialModel
130
- klass . connection . create_table ( :spatial_models , force : true ) do |t |
130
+ klass . lease_connection . create_table ( :spatial_models , force : true ) do |t |
131
131
t . multi_polygon ( :areas , srid : 4326 )
132
132
end
133
133
klass . reset_column_information
@@ -152,14 +152,14 @@ def test_readme_example
152
152
spatial_factory_store . register ( geo_factory , geo_type : "point" , sql_type : "geography" )
153
153
154
154
klass = SpatialModel
155
- klass . connection . create_table ( :spatial_models , force : true ) do |t |
155
+ klass . lease_connection . create_table ( :spatial_models , force : true ) do |t |
156
156
t . column ( :shape , :geometry )
157
157
t . line_string ( :path , srid : 3785 )
158
158
t . st_point ( :latlon , geographic : true )
159
159
end
160
160
klass . reset_column_information
161
161
assert_includes klass . columns . map ( &:name ) , "shape"
162
- klass . connection . change_table ( :spatial_models ) do |t |
162
+ klass . lease_connection . change_table ( :spatial_models ) do |t |
163
163
t . index ( :latlon , using : :gist )
164
164
end
165
165
@@ -192,7 +192,7 @@ def test_custom_column
192
192
end
193
193
194
194
def test_multi_polygon_column
195
- SpatialModel . connection . create_table ( :spatial_models , force : true ) do |t |
195
+ SpatialModel . lease_connection . create_table ( :spatial_models , force : true ) do |t |
196
196
t . column "m_poly" , :multi_polygon
197
197
end
198
198
SpatialModel . reset_column_information
@@ -212,7 +212,7 @@ def test_multi_polygon_column
212
212
private
213
213
214
214
def create_model
215
- SpatialModel . connection . create_table ( :spatial_models , force : true ) do |t |
215
+ SpatialModel . lease_connection . create_table ( :spatial_models , force : true ) do |t |
216
216
t . column "latlon" , :st_point , srid : 3785
217
217
t . column "latlon_geo" , :st_point , srid : 4326 , geographic : true
218
218
t . column "default_latlon" , :st_point , srid : 0 , default : "POINT(0.0 0.0)"
0 commit comments