]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/geocoder_controller_test.rb
Reverse coordinates order only when called with two nondescript numbers
[rails.git] / test / controllers / geocoder_controller_test.rb
index 0d062cf4237abea2da71bb1f75502044cd746eff..3f6e25ea6ae0c16a9e59d70f4e756b85f6b2f56b 100644 (file)
@@ -13,10 +13,6 @@ class GeocoderControllerTest < ActionController::TestCase
       { :path => "/geocoder/search_latlon", :method => :get },
       { :controller => "geocoder", :action => "search_latlon" }
     )
-    assert_routing(
-      { :path => "/geocoder/search_uk_postcode", :method => :get },
-      { :controller => "geocoder", :action => "search_uk_postcode" }
-    )
     assert_routing(
       { :path => "/geocoder/search_ca_postcode", :method => :get },
       { :controller => "geocoder", :action => "search_ca_postcode" }
@@ -263,7 +259,7 @@ class GeocoderControllerTest < ActionController::TestCase
       "CR2 6XH",
       "DN55 1PT"
     ].each do |code|
-      search_check code, %w[uk_postcode osm_nominatim]
+      search_check code, %w[osm_nominatim]
     end
   end
 
@@ -298,22 +294,28 @@ class GeocoderControllerTest < ActionController::TestCase
     results_check_error "Longitude 180.23 out of range"
   end
 
-  ##
-  # Test the UK postcode search
-  def test_search_uk_postcode
-    with_http_stubs "npemap" do
-      get :search_uk_postcode, :xhr => true,
-                               :params => { :query => "CV4 7AL", :zoom => 10,
-                                            :minlon => -0.559, :minlat => 51.217,
-                                            :maxlon => 0.836, :maxlat => 51.766 }
-      results_check :name => "CV4 7AL", :lat => 52.381748701968, :lon => -1.56176420939232
+  def test_search_latlon_digits
+    get :search_latlon, :params => { :lat => 1.23, :lon => 4.56, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check({ :name => "1.23, 4.56", :lat => 1.23, :lon => 4.56, :zoom => 16 },
+                  { :name => "4.56, 1.23", :lat => 4.56, :lon => 1.23, :zoom => 16 })
 
-      get :search_uk_postcode, :xhr => true,
-                               :params => { :query => "XX9 9XX", :zoom => 10,
-                                            :minlon => -0.559, :minlat => 51.217,
-                                            :maxlon => 0.836, :maxlat => 51.766 }
-      results_check
-    end
+    get :search_latlon, :params => { :lat => -91.23, :lon => 4.56, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check :name => "4.56, -91.23", :lat => 4.56, :lon => -91.23, :zoom => 16
+
+    get :search_latlon, :params => { :lat => -1.23, :lon => 170.23, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check :name => "-1.23, 170.23", :lat => -1.23, :lon => 170.23, :zoom => 16
+
+    get :search_latlon, :params => { :lat => 91.23, :lon => 94.56, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check_error "Latitude or longitude are out of range"
+
+    get :search_latlon, :params => { :lat => -91.23, :lon => -94.56, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check_error "Latitude or longitude are out of range"
+
+    get :search_latlon, :params => { :lat => 1.23, :lon => -180.23, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check_error "Latitude or longitude are out of range"
+
+    get :search_latlon, :params => { :lat => 1.23, :lon => 180.23, :zoom => 16, :latlon_digits => true }, :xhr => true
+    results_check_error "Latitude or longitude are out of range"
   end
 
   ##