Skip to content

Commit 40a647b

Browse files
johnnyshieldsp
andauthored
MONGOID-5322: Remove deprecated geo_spacial method (was aliased to geo_spatial) (#5241)
* Remove deprecated geo_spacial method and replace with geo_spatial. * adjust release notes Co-authored-by: shields <[email protected]> Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent 33f2340 commit 40a647b

File tree

3 files changed

+85
-100
lines changed

3 files changed

+85
-100
lines changed

docs/release-notes/mongoid-8.0.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,11 @@ Removed ``Document#to_a`` method
308308

309309
The previously deprecated ``Document#to_a`` method has been removed in
310310
Mongoid 8.
311+
312+
313+
Replaced ``Mongoid::Criteria#geo_spacial`` with ``#geo_spatial``
314+
----------------------------------------------------------------
315+
316+
The previously deprecated ``Mongoid::Criteria#geo_spacial`` method has been
317+
removed in Mongoid 8. It has been replaced one-for-one with ``#geo_spatial``
318+
which was added in Mongoid 7.2.0.

lib/mongoid/criteria/queryable/selectable.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ module Queryable
1010
module Selectable
1111
extend Macroable
1212

13-
Mongoid.deprecate(self, :geo_spacial)
14-
1513
# Constant for a LineString $geometry.
1614
LINE_STRING = "LineString"
1715

@@ -229,19 +227,6 @@ def geo_spatial(criterion)
229227
__merge__(criterion)
230228
end
231229

232-
# Alias for +geo_spatial+.
233-
#
234-
# @deprecated
235-
def geo_spacial(criterion)
236-
# Duplicate method body so that we can raise this exception with
237-
# geo_spacial as the indicated operator rather than geo_spatial.
238-
if criterion.nil?
239-
raise Errors::CriteriaArgumentRequired, :geo_spacial
240-
end
241-
242-
__merge__(criterion)
243-
end
244-
245230
key :intersects_line, :override, "$geoIntersects", "$geometry" do |value|
246231
{ "type" => LINE_STRING, "coordinates" => value }
247232
end

spec/mongoid/criteria/queryable/selectable_spec.rb

Lines changed: 77 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -695,127 +695,119 @@ def localized?
695695
end
696696
end
697697

698-
%i(geo_spatial geo_spacial).each do |meth|
699-
describe "#geo_spacial" do
698+
describe "#geo_spatial" do
700699

701-
let(:query_method) { meth }
700+
let(:query_method) { :geo_spatial }
702701

703-
it_behaves_like 'requires an argument'
704-
it_behaves_like 'requires a non-nil argument'
702+
it_behaves_like 'requires an argument'
703+
it_behaves_like 'requires a non-nil argument'
705704

706-
context "when provided a criterion" do
705+
context "when provided a criterion" do
707706

708-
context "when the geometry is a point intersection" do
707+
context "when the geometry is a point intersection" do
709708

710-
let(:selection) do
711-
query.public_send(query_method, :location.intersects_point => [ 1, 10 ])
712-
end
709+
let(:selection) do
710+
query.geo_spatial(:location.intersects_point => [ 1, 10 ])
711+
end
713712

714-
it "adds the $geoIntersects expression" do
715-
expect(selection.selector).to eq({
716-
"location" => {
717-
"$geoIntersects" => {
718-
"$geometry" => {
719-
"type" => "Point",
720-
"coordinates" => [ 1, 10 ]
721-
}
713+
it "adds the $geoIntersects expression" do
714+
expect(selection.selector).to eq({
715+
"location" => {
716+
"$geoIntersects" => {
717+
"$geometry" => {
718+
"type" => "Point",
719+
"coordinates" => [ 1, 10 ]
722720
}
723721
}
724-
})
725-
end
726-
727-
it_behaves_like "returns a cloned query"
722+
}
723+
})
728724
end
729725

730-
context "when the geometry is a line intersection" do
726+
it_behaves_like "returns a cloned query"
727+
end
731728

732-
let(:selection) do
733-
query.public_send(query_method, :location.intersects_line => [[ 1, 10 ], [ 2, 10 ]])
734-
end
729+
context "when the geometry is a line intersection" do
735730

736-
it "adds the $geoIntersects expression" do
737-
expect(selection.selector).to eq({
738-
"location" => {
739-
"$geoIntersects" => {
740-
"$geometry" => {
741-
"type" => "LineString",
742-
"coordinates" => [[ 1, 10 ], [ 2, 10 ]]
743-
}
731+
let(:selection) do
732+
query.geo_spatial(:location.intersects_line => [[ 1, 10 ], [ 2, 10 ]])
733+
end
734+
735+
it "adds the $geoIntersects expression" do
736+
expect(selection.selector).to eq({
737+
"location" => {
738+
"$geoIntersects" => {
739+
"$geometry" => {
740+
"type" => "LineString",
741+
"coordinates" => [[ 1, 10 ], [ 2, 10 ]]
744742
}
745743
}
746-
})
747-
end
748-
749-
it_behaves_like "returns a cloned query"
744+
}
745+
})
750746
end
751747

752-
context "when the geometry is a polygon intersection" do
748+
it_behaves_like "returns a cloned query"
749+
end
753750

754-
let(:selection) do
755-
query.public_send(query_method,
756-
:location.intersects_polygon => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]]
757-
)
758-
end
751+
context "when the geometry is a polygon intersection" do
759752

760-
it "adds the $geoIntersects expression" do
761-
expect(selection.selector).to eq({
762-
"location" => {
763-
"$geoIntersects" => {
764-
"$geometry" => {
765-
"type" => "Polygon",
766-
"coordinates" => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]]
767-
}
753+
let(:selection) do
754+
query.geo_spatial(:location.intersects_polygon => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]])
755+
end
756+
757+
it "adds the $geoIntersects expression" do
758+
expect(selection.selector).to eq({
759+
"location" => {
760+
"$geoIntersects" => {
761+
"$geometry" => {
762+
"type" => "Polygon",
763+
"coordinates" => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]]
768764
}
769765
}
770-
})
771-
end
766+
}
767+
})
768+
end
769+
770+
it_behaves_like "returns a cloned query"
771+
end
772+
773+
context "when the geometry is within a polygon" do
772774

773-
it_behaves_like "returns a cloned query"
775+
let(:selection) do
776+
query.geo_spatial(:location.within_polygon => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]])
774777
end
775778

776-
context "when the geometry is within a polygon" do
779+
it "adds the $geoIntersects expression" do
780+
expect(selection.selector).to eq({
781+
"location" => {
782+
"$geoWithin" => {
783+
"$geometry" => {
784+
"type" => "Polygon",
785+
"coordinates" => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]]
786+
}
787+
}
788+
}
789+
})
790+
end
777791

792+
context "when used with the $box operator ($geoWithin query) " do
778793
let(:selection) do
779-
query.public_send(query_method,
780-
:location.within_polygon => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]]
781-
)
794+
query.geo_spatial(:location.within_box => [[ 1, 10 ], [ 2, 10 ]])
782795
end
783796

784797
it "adds the $geoIntersects expression" do
785798
expect(selection.selector).to eq({
786799
"location" => {
787800
"$geoWithin" => {
788-
"$geometry" => {
789-
"type" => "Polygon",
790-
"coordinates" => [[[ 1, 10 ], [ 2, 10 ], [ 1, 10 ]]]
791-
}
801+
"$box" => [
802+
[ 1, 10 ], [ 2, 10 ]
803+
]
792804
}
793805
}
794806
})
795807
end
796-
797-
context "when used with the $box operator ($geoWithin query) " do
798-
let(:selection) do
799-
query.public_send(query_method,
800-
:location.within_box => [[ 1, 10 ], [ 2, 10 ]]
801-
)
802-
end
803-
804-
it "adds the $geoIntersects expression" do
805-
expect(selection.selector).to eq({
806-
"location" => {
807-
"$geoWithin" => {
808-
"$box" => [
809-
[ 1, 10 ], [ 2, 10 ]
810-
]
811-
}
812-
}
813-
})
814-
end
815-
end
816-
817-
it_behaves_like "returns a cloned query"
818808
end
809+
810+
it_behaves_like "returns a cloned query"
819811
end
820812
end
821813
end

0 commit comments

Comments
 (0)