Skip to content

Commit

Permalink
fix test teardown (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
formigarafa authored Oct 17, 2024
1 parent 956e5f8 commit 4f6ebe6
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions test/cases/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

module PostGIS
class BasicTest < ActiveSupport::TestCase
def before
reset_spatial_store
end

def after
def teardown
reset_spatial_store
end

Expand Down Expand Up @@ -121,16 +117,13 @@ def test_custom_factory
end
klass.reset_column_information
custom_factory = RGeo::Geographic.spherical_factory(buffer_resolution: 8, srid: 4326)
old_registry = spatial_factory_store.registry
spatial_factory_store.register(custom_factory, geo_type: "polygon", srid: 4326)
object = klass.new
area = custom_factory.point(1, 2).buffer(3)
object.area = area
object.save!
object.reload
assert_equal area, object.area
ensure
spatial_factory_store.registry = old_registry
end

def test_spatial_factory_attrs_parsing
Expand All @@ -140,29 +133,23 @@ def test_spatial_factory_attrs_parsing
end
klass.reset_column_information
factory = RGeo::Cartesian.preferred_factory(srid: 4326)
old_registry = spatial_factory_store.registry
spatial_factory_store.register(factory, { srid: 4326,
sql_type: "geometry",
geo_type: "multi_polygon",
has_z: false, has_m: false })

# wrong factory for default
old_default = spatial_factory_store.instance_variable_get :@default
spatial_factory_store.default = RGeo::Geographic.spherical_factory(srid: 4326)

object = klass.new
object.areas = "MULTIPOLYGON (((0 0, 0 1, 1 1, 1 0, 0 0)))"
object.save!
object.reload
assert_equal(factory, object.areas.factory)
ensure
spatial_factory_store.registry = old_registry
spatial_factory_store.default = old_default
end

def test_readme_example
geo_factory = RGeo::Geographic.spherical_factory(srid: 4326)
old_registry = spatial_factory_store.registry
spatial_factory_store.register(geo_factory, geo_type: "point", sql_type: "geography")

klass = SpatialModel
Expand All @@ -187,8 +174,6 @@ def test_readme_example
object.save!
object.reload
refute_equal geo_factory, object.shape.factory
ensure
spatial_factory_store.registry = old_registry
end

def test_point_to_json
Expand Down

0 comments on commit 4f6ebe6

Please sign in to comment.