Sha256: 1aab218bdfe4cd766cf0a594b464ee4841924f9036639e0304fc6ec39c812d48
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
require File.expand_path('../spec_helper', File.dirname(__FILE__)) describe "geospatial search" do describe "filtering by radius" do before :all do Sunspot.remove_all @post = Post.new(:title => "Howdy", :coordinates => Sunspot::Util::Coordinates.new(32, -68)) Sunspot.index!(@post) end it "matches posts with the radius" do results = Sunspot.search(Post) { with(:coordinates_new).in_radius(32, -68, 1) }.results results.should include(@post) end it "filters out posts not in the radius" do results = Sunspot.search(Post) { with(:coordinates_new).in_radius(33, -68, 1) }.results results.should_not include(@post) end end describe "ordering by geodist" do before :all do Sunspot.remove_all @posts = [ Post.new(:title => "Howdy", :coordinates => Sunspot::Util::Coordinates.new(34, -68)), Post.new(:title => "Howdy", :coordinates => Sunspot::Util::Coordinates.new(33, -68)), Post.new(:title => "Howdy", :coordinates => Sunspot::Util::Coordinates.new(32, -68)) ] Sunspot.index!(@posts) end it "orders posts by distance ascending" do results = Sunspot.search(Post) { order_by_geodist(:coordinates_new, 32, -68) }.results results.should == @posts.reverse end it "orders posts by distance descending" do results = Sunspot.search(Post) { order_by_geodist(:coordinates_new, 32, -68, :desc) }.results results.should == @posts end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sunspot-2.0.0.pre.111215 | spec/integration/geospatial_spec.rb |