Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

still working for mongoid spec

  • Loading branch information...
commit fe1e116c8e596ba3d371428fcc2f6495c8378339 1 parent f284a45
niedhui niedhui authored
5 lib/mongoid_geospatial/contextual/mongo.rb
@@ -31,7 +31,7 @@ class Mongo #:nodoc:
31 31 #
32 32 # @return [ Array ] Sorted Rows
33 33 def geo_near(center, opts = {})
34   -# opts = self.options.merge(opts)
  34 + opts = self.criteria.options.merge(opts)
35 35 # convert point
36 36 center = center.to_xy if center.respond_to?(:to_xy)
37 37 center = [center.x, center.y] if center.respond_to?(:x)
@@ -69,6 +69,7 @@ def geo_near(center, opts = {})
69 69 end
70 70 opts[:query] = create_geo_near_query(center,opts)
71 71 results = klass.mongo_session.command(opts[:query])
  72 +
72 73 Mongoid::Geospatial::GeoNearResults.new(klass,results,opts)
73 74 end
74 75
@@ -76,7 +77,7 @@ def geo_near(center, opts = {})
76 77
77 78 def create_geo_near_query(center,opts)
78 79 # minimum query
79   - query = {}
  80 + query = {}
80 81 query[:geoNear] = klass.collection_name
81 82 query[:near] = center
82 83
2  spec/functional/contexts/mongo_spec.rb
... ... @@ -1,6 +1,6 @@
1 1 require "spec_helper"
2 2
3   -describe Mongoid::Contexts::Mongo do
  3 +describe (Mongoid::VERSION > '3' ? Mongoid::Contextual::Mongo : Mongoid::Contexts::Mongo) do
4 4 describe "#geo_near" do
5 5
6 6 before do
4 spec/spec_helper.rb
@@ -43,6 +43,10 @@
43 43
44 44 Dir[ File.join(SUPPORT, "*.rb") ].each { |file| require File.basename(file) }
45 45
  46 +def bson_object_id_class
  47 + Mongoid::VERSION > '3' ? Moped::BSON:: ObjectId : BSON::ObjectId
  48 +end
  49 +
46 50 RSpec.configure do |config|
47 51 config.mock_with(:mocha)
48 52

0 comments on commit fe1e116

Please sign in to comment.
Something went wrong with that request. Please try again.