Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

still working for mongoid spec

  • Loading branch information...
commit fe1e116c8e596ba3d371428fcc2f6495c8378339 1 parent f284a45
@niedhui niedhui authored
View
5 lib/mongoid_geospatial/contextual/mongo.rb
@@ -31,7 +31,7 @@ class Mongo #:nodoc:
#
# @return [ Array ] Sorted Rows
def geo_near(center, opts = {})
-# opts = self.options.merge(opts)
+ opts = self.criteria.options.merge(opts)
# convert point
center = center.to_xy if center.respond_to?(:to_xy)
center = [center.x, center.y] if center.respond_to?(:x)
@@ -69,6 +69,7 @@ def geo_near(center, opts = {})
end
opts[:query] = create_geo_near_query(center,opts)
results = klass.mongo_session.command(opts[:query])
+
Mongoid::Geospatial::GeoNearResults.new(klass,results,opts)
end
@@ -76,7 +77,7 @@ def geo_near(center, opts = {})
def create_geo_near_query(center,opts)
# minimum query
- query = {}
+ query = {}
query[:geoNear] = klass.collection_name
query[:near] = center
View
2  spec/functional/contexts/mongo_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Mongoid::Contexts::Mongo do
+describe (Mongoid::VERSION > '3' ? Mongoid::Contextual::Mongo : Mongoid::Contexts::Mongo) do
describe "#geo_near" do
before do
View
4 spec/spec_helper.rb
@@ -43,6 +43,10 @@
Dir[ File.join(SUPPORT, "*.rb") ].each { |file| require File.basename(file) }
+def bson_object_id_class
+ Mongoid::VERSION > '3' ? Moped::BSON:: ObjectId : BSON::ObjectId
+end
+
RSpec.configure do |config|
config.mock_with(:mocha)
Please sign in to comment.
Something went wrong with that request. Please try again.