From 86f418fde8e8e94a5ec8e512b7230b92759f1fa9 Mon Sep 17 00:00:00 2001
From: Anderson Bravalheri <andersonbravalheri@gmail.com>
Date: Thu, 21 Jul 2011 01:54:56 -0300
Subject: [PATCH] Tests to the configuration chain included.

---
 test/configuration_test.rb | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/test/configuration_test.rb b/test/configuration_test.rb
index 37171aee..78d0ca56 100644
--- a/test/configuration_test.rb
+++ b/test/configuration_test.rb
@@ -83,5 +83,22 @@ class ConfigurationTest < Test::Unit::TestCase
     v.longitude = -73.993371
     assert_equal 136, v.bearing_from([50,-85]).round
   end
+
+  def test_configuration_chain
+    v = Landmark.new(*landmark_params(:msg))
+    v.latitude  = 0
+    v.longitude = 0
+
+    # method option > global configuration
+    Geocoder.configure.units  = :km
+    assert_equal 69, v.distance_to([0,1], :mi).round
+
+    # per-model configuration > global configuration
+    Landmark.reverse_geocoded_by :latitude, :longitude, :method => :spherical, :units => :mi
+    assert_equal 69, v.distance_to([0,1]).round
+
+    # method option > per-model configuration
+    assert_equal 111, v.distance_to([0,1], :km).round
+  end
 end
 
-- 
GitLab