Skip to content

Commit

Permalink
fix: use lease_connection in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Sep 5, 2024
1 parent c21dbce commit 28cab3a
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 226 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ jobs:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
TESTOPTS: --verbose --name=/PostgresqlHstoreTest/
2 changes: 1 addition & 1 deletion activerecord-postgis-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|

spec.version = ActiveRecord::ConnectionAdapters::PostGIS::VERSION
spec.authors = ["Daniel Azuma", "Tee Parham"]
spec.email = ["kfdoggett@gmail.com", "buonomo.ulysse@gmail.com"]
spec.email = ["kfdoggett@gmail.com", "buonomo.ulysse@gmail.com", "terminale@gmail.com"]
spec.homepage = "http://github.com/rgeo/activerecord-postgis-adapter"
spec.license = "BSD-3-Clause"

Expand Down
6 changes: 3 additions & 3 deletions test/cases/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ def test_joined_spatial_attribute
private

def create_foo
Foo.connection.create_table :foos, force: true do |t|
Foo.lease_connection.create_table :foos, force: true do |t|
end
end

def create_spatial_foo
SpatialFoo.connection.create_table :spatial_foos, force: true do |t|
SpatialFoo.lease_connection.create_table :spatial_foos, force: true do |t|
t.references :foo
t.st_point :geo_point, geographic: true, srid: 4326
t.st_point :cart_point, srid: 3509
end
end

def create_invalid_attributes
InvalidAttribute.connection.create_table :invalid_attributes, force: true do |t|
InvalidAttribute.lease_connection.create_table :invalid_attributes, force: true do |t|
end
end
end
Expand Down
22 changes: 11 additions & 11 deletions test/cases/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ def test_version
end

def test_postgis_available
assert_equal "PostGIS", SpatialModel.connection.adapter_name
assert_equal postgis_version, SpatialModel.connection.postgis_lib_version
valid_version = ["2.", "3."].any? { |major_ver| SpatialModel.connection.postgis_lib_version.start_with? major_ver }
assert_equal "PostGIS", SpatialModel.lease_connection.adapter_name
assert_equal SpatialModel.lease_connection.select_value("SELECT postgis_lib_version()"), SpatialModel.lease_connection.postgis_lib_version
valid_version = ["2.", "3."].any? { |major_ver| SpatialModel.lease_connection.postgis_lib_version.start_with? major_ver }
assert valid_version
end

def test_arel_visitor
visitor = Arel::Visitors::PostGIS.new(SpatialModel.connection)
visitor = Arel::Visitors::PostGIS.new(SpatialModel.lease_connection)
node = RGeo::ActiveRecord::SpatialConstantNode.new("POINT (1.0 2.0)")
collector = Arel::Collectors::PlainString.new
visitor.accept(node, collector)
assert_equal "ST_GeomFromText('POINT (1.0 2.0)')", collector.value
end

def test_arel_visitor_will_not_visit_string
visitor = Arel::Visitors::PostGIS.new(SpatialModel.connection)
visitor = Arel::Visitors::PostGIS.new(SpatialModel.lease_connection)
node = "POINT (1 2)"
collector = Arel::Collectors::PlainString.new

Expand Down Expand Up @@ -111,7 +111,7 @@ def test_default_value

def test_custom_factory
klass = SpatialModel
klass.connection.create_table(:spatial_models, force: true) do |t|
klass.lease_connection.create_table(:spatial_models, force: true) do |t|
t.st_polygon(:area, srid: 4326)
end
klass.reset_column_information
Expand All @@ -127,7 +127,7 @@ def test_custom_factory

def test_spatial_factory_attrs_parsing
klass = SpatialModel
klass.connection.create_table(:spatial_models, force: true) do |t|
klass.lease_connection.create_table(:spatial_models, force: true) do |t|
t.multi_polygon(:areas, srid: 4326)
end
klass.reset_column_information
Expand All @@ -152,14 +152,14 @@ def test_readme_example
spatial_factory_store.register(geo_factory, geo_type: "point", sql_type: "geography")

klass = SpatialModel
klass.connection.create_table(:spatial_models, force: true) do |t|
klass.lease_connection.create_table(:spatial_models, force: true) do |t|
t.column(:shape, :geometry)
t.line_string(:path, srid: 3785)
t.st_point(:latlon, geographic: true)
end
klass.reset_column_information
assert_includes klass.columns.map(&:name), "shape"
klass.connection.change_table(:spatial_models) do |t|
klass.lease_connection.change_table(:spatial_models) do |t|
t.index(:latlon, using: :gist)
end

Expand Down Expand Up @@ -192,7 +192,7 @@ def test_custom_column
end

def test_multi_polygon_column
SpatialModel.connection.create_table(:spatial_models, force: true) do |t|
SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t|
t.column "m_poly", :multi_polygon
end
SpatialModel.reset_column_information
Expand All @@ -212,7 +212,7 @@ def test_multi_polygon_column
private

def create_model
SpatialModel.connection.create_table(:spatial_models, force: true) do |t|
SpatialModel.lease_connection.create_table(:spatial_models, force: true) do |t|
t.column "latlon", :st_point, srid: 3785
t.column "latlon_geo", :st_point, srid: 4326, geographic: true
t.column "default_latlon", :st_point, srid: 0, default: "POINT(0.0 0.0)"
Expand Down
Loading

0 comments on commit 28cab3a

Please sign in to comment.