Permalink
Browse files

Return an array of lat, lon instead of a string.

  • Loading branch information...
dblock committed Sep 27, 2018
1 parent 7ceb392 commit 098ff17148e30898e8efed3645a757750614132b
@@ -3,5 +3,5 @@
description 'Geo coordinate, latitude followed by longitude.'

coerce_input ->(value, _ctx) { Geo::Coord.parse(value) }
coerce_result ->(value, _ctx) { value.to_s }
coerce_result ->(value, _ctx) { [value.y, value.x] }
end
@@ -1,8 +1,8 @@
module Mongoid
module Geospatial
class Point
def to_s
Geo::Coord.new(y, x).to_s
def to_a
[y, x]
end
end
end
@@ -43,7 +43,7 @@
expect(meeting.title).to eq title
expect(DateTime.parse(meeting.started)).to eq started_at.utc.iso8601
expect(DateTime.parse(meeting.finished)).to eq finished_at.utc.iso8601
expect(Geo::Coord.parse(meeting.location)).to eq location
expect(meeting.location).to eq [location.latitude, location.longitude]

edge = response.data.create_meeting.meeting_edge
expect(edge.node.id).to eq meeting.id
@@ -43,8 +43,8 @@
}
)
update_meeting = response.data.update_meeting.meeting
expect(update_meeting.location).to eq "50°0'16\"N 36°13'53\"E"
expect(meeting.reload.location.to_s).to eq "50°0'16\"N 36°13'53\"E"
expect(update_meeting.location).to eq [50.004444, 36.231389]
expect(meeting.reload.location.to_a).to eq [50.004444, 36.231389]
end

it 'fails with an invalid location' do
@@ -28,6 +28,6 @@
expect(returned_meeting.title).to eq meeting.title
expect(returned_meeting.started).to eq meeting.started_at.utc.iso8601
expect(returned_meeting.finished).to eq meeting.finished_at.utc.iso8601
expect(returned_meeting.location).to eq meeting.location.to_s
expect(returned_meeting.location).to eq meeting.location.to_a
end
end

0 comments on commit 098ff17

Please sign in to comment.