diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 598d06370cb410613c975f4578b5bf063ce89818..37171aee77043c8fc188415793b2c0040d1b3f10 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -72,16 +72,16 @@ class ConfigurationTest < Test::Unit::TestCase # Geocoder per-model configuration def test_model_configuration Landmark.reverse_geocoded_by :latitude, :longitude, :method => :spherical, :units => :km - assert_equal Landmark.geocoder_options[:units], :km + assert_equal :km, Landmark.geocoder_options[:units] assert_equal :spherical, Landmark.geocoder_options[:method] - venue = Landmark.new(*landmark_params(:msg)) - venue.latitude = 0 - venue.longitude = 0 - assert_equal 111, venue.distance_to([0,1]).round - venue.latitude = 40.750354 - venue.longitude = -73.993371 - assert_equal 136, venue.bearing_from([50,-85]).round + v = Landmark.new(*landmark_params(:msg)) + v.latitude = 0 + v.longitude = 0 + assert_equal 111, v.distance_to([0,1]).round + v.latitude = 40.750354 + v.longitude = -73.993371 + assert_equal 136, v.bearing_from([50,-85]).round end end diff --git a/test/mongoid_test.rb b/test/mongoid_test.rb index c4fb8ae07251f61f3c52480838b308c5ed9e3e36..7b8f41479411abf7c69b5c620c78a37c4dca7fbd 100644 --- a/test/mongoid_test.rb +++ b/test/mongoid_test.rb @@ -28,8 +28,20 @@ class MongoidTest < Test::Unit::TestCase p = Place.near(location) assert_equal p.selector[:location]['$nearSphere'], location.reverse end + + def test_model_configuration + p = Place.new(*venue_params(:msg)) + p.location = [0, 0] + + Place.geocoded_by :address, :coordinates => :location, :units => :km + assert_equal 111, p.distance_to([0,1]).round + + Place.geocoded_by :address, :coordinates => :location, :units => :mi + assert_equal 69, p.distance_to([0,1]).round + end end rescue LoadError => crash warn 'Mongoid not installed, not tested.' end +