Permalink
Browse files

still working for mongoid spec

  • Loading branch information...
1 parent f284a45 commit fe1e116c8e596ba3d371428fcc2f6495c8378339 @niedhui committed Jul 26, 2012
Showing with 8 additions and 3 deletions.
  1. +3 −2 lib/mongoid_geospatial/contextual/mongo.rb
  2. +1 −1 spec/functional/contexts/mongo_spec.rb
  3. +4 −0 spec/spec_helper.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,14 +69,15 @@ 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
private
def create_geo_near_query(center,opts)
# minimum query
- query = {}
+ query = {}
query[:geoNear] = klass.collection_name
query[:near] = center
@@ -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
@@ -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)

0 comments on commit fe1e116

Please sign in to comment.