Skip to content
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

8.0 stable #388

Merged
merged 10 commits into from
Dec 5, 2023
7 changes: 5 additions & 2 deletions test/cases/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def test_set_point_wkt_wrong_type
def test_default_value
create_model
obj = SpatialModel.create
assert_equal factory.point(0, 0).to_s, obj.default_latlon.to_s
assert_equal factory.point(0, 0).x, obj.default_latlon.x
assert_equal factory.point(0, 0).y, obj.default_latlon.y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the bigger issue we're trying to look at here is that we should be able to compare by rgeo objects and not their attributes.

assert_equal factory.point(0,0), obj.default_latlon

should work but it's not for some reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this issue

end

def test_custom_factory
Expand All @@ -122,7 +123,9 @@ def test_custom_factory
object.area = area
object.save!
object.reload
assert_equal area.to_s, object.area.to_s
area_p = MyPolygon.new(area)
obj_area_p = MyPolygon.new(object.area)
assert_equal area_p, obj_area_p
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to change this back to comparing area and object.area directly. We can remove the MyPolygon class as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

end

def test_spatial_factory_attrs_parsing
Expand Down
14 changes: 14 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require "erb"
require "byebug" if ENV["BYEBUG"]
require "activerecord-postgis-adapter"
require 'rgeo'

if ENV["ARCONN"]
# only install activerecord schema if we need it
Expand Down Expand Up @@ -65,6 +66,19 @@ def self.establish_test_connection
class SpatialModel < ActiveRecord::Base
end

class MyPolygon
attr_accessor :polygon

def initialize(polygon)
@polygon = polygon
end

def ==(other)
# Compare polygons based on their WKT (Well-Known Text) representation
@polygon.as_text == other.polygon.as_text
end
end

module ActiveSupport
class TestCase
self.test_order = :sorted
Expand Down