Skip to content

Commit

Permalink
undid freeze on distance and added spec to ensure distance can be cal…
Browse files Browse the repository at this point in the history
…culated and set multiple times for same instance
  • Loading branch information
kristianmandrup committed Mar 4, 2011
1 parent f26af8a commit 6f400b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/mongoid/geo/geo_near.rb
Expand Up @@ -10,7 +10,6 @@ module Distance

def set_distance dist
@distance = dist
@distance.freeze
end
end

Expand Down
2 changes: 1 addition & 1 deletion mongoid_geo.gemspec
Expand Up @@ -18,5 +18,5 @@ Gem::Specification.new do |s|
s.add_dependency 'activesupport', '>= 3.0.4'
s.add_dependency 'hashie', '>= 0.4.0' # https://github.com/okiess/mongo-hashie ???

s.version = "0.2.4"
s.version = "0.2.5"
end
7 changes: 6 additions & 1 deletion spec/mongoid/geo/geo_near_spec.rb
Expand Up @@ -36,10 +36,15 @@
it "should return model" do
address.location = "23.5, -47"
my_model = Address.geoNear(address, :location, :num => 1).first.to_model
my_model.lat.should == 45
my_model.lat.should == 45
first_dist = my_model.distance
my_model.distance.should > 6000
lambda {my_model.distance = 500}.should raise_error
my_model.distance.should > 6000

address.location = "27.5, 12"
my_model = Address.geoNear(address, :location, :num => 1).first.to_model
my_model.distance.should_not == first_dist
end
end

Expand Down

0 comments on commit 6f400b9

Please sign in to comment.