Skip to content

Fix test teardown #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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