X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/87918595da1e1fad2ddd7aa62f9fc537dff657ff..5b4a8ba58705cc3fdcf574e6aa2b9594a7778fe0:/test/controllers/geocoder_controller_test.rb diff --git a/test/controllers/geocoder_controller_test.rb b/test/controllers/geocoder_controller_test.rb index ee8991d48..98f427fca 100644 --- a/test/controllers/geocoder_controller_test.rb +++ b/test/controllers/geocoder_controller_test.rb @@ -1,4 +1,3 @@ - require "test_helper" require "geocoder_controller" @@ -14,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" } @@ -264,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 @@ -284,37 +279,26 @@ class GeocoderControllerTest < ActionController::TestCase # Test the builtin latitude+longitude search def test_search_latlon get :search_latlon, :params => { :lat => 1.23, :lon => 4.56, :zoom => 16 }, :xhr => true - results_check :name => "1.23, 4.56", :lat => 1.23, :lon => 4.56, :zoom => 16 + 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_latlon, :params => { :lat => -91.23, :lon => 4.56, :zoom => 16 }, :xhr => true - results_check_error "Latitude -91.23 out of range" + results_check :name => "4.56, -91.23", :lat => 4.56, :lon => -91.23, :zoom => 16 - get :search_latlon, :params => { :lat => 91.23, :lon => 4.56, :zoom => 16 }, :xhr => true - results_check_error "Latitude 91.23 out of range" + get :search_latlon, :params => { :lat => -1.23, :lon => 170.23, :zoom => 16 }, :xhr => true + results_check :name => "-1.23, 170.23", :lat => -1.23, :lon => 170.23, :zoom => 16 - get :search_latlon, :params => { :lat => 1.23, :lon => -180.23, :zoom => 16 }, :xhr => true - results_check_error "Longitude -180.23 out of range" + get :search_latlon, :params => { :lat => 91.23, :lon => 94.56, :zoom => 16 }, :xhr => true + results_check_error "Latitude or longitude are out of range" - get :search_latlon, :params => { :lat => 1.23, :lon => 180.23, :zoom => 16 }, :xhr => true - results_check_error "Longitude 180.23 out of range" - end + get :search_latlon, :params => { :lat => -91.23, :lon => 94.56, :zoom => 16 }, :xhr => true + results_check_error "Latitude or longitude are out of range" - ## - # 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 + get :search_latlon, :params => { :lat => 1.23, :lon => -180.23, :zoom => 16 }, :xhr => true + results_check_error "Latitude or longitude are out of range" - 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 => 1.23, :lon => 180.23, :zoom => 16 }, :xhr => true + results_check_error "Latitude or longitude are out of range" end ## @@ -425,6 +409,12 @@ class GeocoderControllerTest < ActionController::TestCase results_check :name => "Dinant Link Road, Broxbourne, Hertfordshire, East of England, England, EN11 8HX, United Kingdom", :lat => 51.7634883, :lon => -0.0088373, :type => "way", :id => 3489841, :zoom => 17 + + get :search_osm_nominatim_reverse, :xhr => true, + :params => { :lat => 13.7709, :lon => 100.50507, :zoom => 19 } + results_check :name => "MM Steak&Grill, ถนนศรีอยุธยา, บางขุนพรหม, กรุงเทพมหานคร, เขตดุสิต, กรุงเทพมหานคร, 10300, ประเทศไทย", + :lat => 13.7708691, :lon => 100.505073233221, + :type => "way", :id => 542901374, :zoom => 19 end end