Skip to content

Commit 28cab3a

Browse files
committed
fix: use lease_connection in tests
1 parent c21dbce commit 28cab3a

File tree

10 files changed

+85
-226
lines changed

10 files changed

+85
-226
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ jobs:
6767
PGHOST: localhost
6868
PGUSER: postgres
6969
PGPASSWORD: postgres
70+
TESTOPTS: --verbose --name=/PostgresqlHstoreTest/

activerecord-postgis-adapter.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
1010

1111
spec.version = ActiveRecord::ConnectionAdapters::PostGIS::VERSION
1212
spec.authors = ["Daniel Azuma", "Tee Parham"]
13-
13+
1414
spec.homepage = "http://github.com/rgeo/activerecord-postgis-adapter"
1515
spec.license = "BSD-3-Clause"
1616

test/cases/attributes_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,20 @@ def test_joined_spatial_attribute
9999
private
100100

101101
def create_foo
102-
Foo.connection.create_table :foos, force: true do |t|
102+
Foo.lease_connection.create_table :foos, force: true do |t|
103103
end
104104
end
105105

106106
def create_spatial_foo
107-
SpatialFoo.connection.create_table :spatial_foos, force: true do |t|
107+
SpatialFoo.lease_connection.create_table :spatial_foos, force: true do |t|
108108
t.references :foo
109109
t.st_point :geo_point, geographic: true, srid: 4326
110110
t.st_point :cart_point, srid: 3509
111111
end
112112
end
113113

114114
def create_invalid_attributes
115-
InvalidAttribute.connection.create_table :invalid_attributes, force: true do |t|
115+
InvalidAttribute.lease_connection.create_table :invalid_attributes, force: true do |t|
116116
end
117117
end
118118
end

test/cases/basic_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ def test_version
1313
end
1414

1515
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 }
1919
assert valid_version
2020
end
2121

2222
def test_arel_visitor
23-
visitor = Arel::Visitors::PostGIS.new(SpatialModel.connection)
23+
visitor = Arel::Visitors::PostGIS.new(SpatialModel.lease_connection)
2424
node = RGeo::ActiveRecord::SpatialConstantNode.new("POINT (1.0 2.0)")
2525
collector = Arel::Collectors::PlainString.new
2626
visitor.accept(node, collector)
2727
assert_equal "ST_GeomFromText('POINT (1.0 2.0)')", collector.value
2828
end
2929

3030
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)
3232
node = "POINT (1 2)"
3333
collector = Arel::Collectors::PlainString.new
3434

@@ -111,7 +111,7 @@ def test_default_value
111111

112112
def test_custom_factory
113113
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|
115115
t.st_polygon(:area, srid: 4326)
116116
end
117117
klass.reset_column_information
@@ -127,7 +127,7 @@ def test_custom_factory
127127

128128
def test_spatial_factory_attrs_parsing
129129
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|
131131
t.multi_polygon(:areas, srid: 4326)
132132
end
133133
klass.reset_column_information
@@ -152,14 +152,14 @@ def test_readme_example
152152
spatial_factory_store.register(geo_factory, geo_type: "point", sql_type: "geography")
153153

154154
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|
156156
t.column(:shape, :geometry)
157157
t.line_string(:path, srid: 3785)
158158
t.st_point(:latlon, geographic: true)
159159
end
160160
klass.reset_column_information
161161
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|
163163
t.index(:latlon, using: :gist)
164164
end
165165

@@ -192,7 +192,7 @@ def test_custom_column
192192
end
193193

194194
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|
196196
t.column "m_poly", :multi_polygon
197197
end
198198
SpatialModel.reset_column_information
@@ -212,7 +212,7 @@ def test_multi_polygon_column
212212
private
213213

214214
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|
216216
t.column "latlon", :st_point, srid: 3785
217217
t.column "latlon_geo", :st_point, srid: 4326, geographic: true
218218
t.column "default_latlon", :st_point, srid: 0, default: "POINT(0.0 0.0)"

0 commit comments

Comments
 (0)