X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/902ba27de98506448a550e81f58ce7b845ee183b..7417d142998219a94f8cd2eb97fcfed555a99e30:/test/functional/geocoder_controller_test.rb?ds=sidebyside diff --git a/test/functional/geocoder_controller_test.rb b/test/functional/geocoder_controller_test.rb index 6d1d1f1c5..51fc2020a 100644 --- a/test/functional/geocoder_controller_test.rb +++ b/test/functional/geocoder_controller_test.rb @@ -11,10 +11,6 @@ class GeocoderControllerTest < ActionController::TestCase { :path => "/geocoder/search", :method => :post }, { :controller => "geocoder", :action => "search" } ) - assert_routing( - { :path => "/geocoder/search_latlon", :method => :get }, - { :controller => "geocoder", :action => "search_latlon" } - ) assert_routing( { :path => "/geocoder/search_us_postcode", :method => :get }, { :controller => "geocoder", :action => "search_us_postcode" } @@ -27,10 +23,6 @@ class GeocoderControllerTest < ActionController::TestCase { :path => "/geocoder/search_ca_postcode", :method => :get }, { :controller => "geocoder", :action => "search_ca_postcode" } ) - assert_routing( - { :path => "/geocoder/search_osm_namefinder", :method => :get }, - { :controller => "geocoder", :action => "search_osm_namefinder" } - ) assert_routing( { :path => "/geocoder/search_osm_nominatim", :method => :get }, { :controller => "geocoder", :action => "search_osm_nominatim" } @@ -39,22 +31,13 @@ class GeocoderControllerTest < ActionController::TestCase { :path => "/geocoder/search_geonames", :method => :get }, { :controller => "geocoder", :action => "search_geonames" } ) - - assert_routing( - { :path => "/geocoder/description", :method => :post }, - { :controller => "geocoder", :action => "description" } - ) assert_routing( - { :path => "/geocoder/description_osm_namefinder", :method => :get }, - { :controller => "geocoder", :action => "description_osm_namefinder" } + { :path => "/geocoder/search_osm_nominatim_reverse", :method => :get }, + { :controller => "geocoder", :action => "search_osm_nominatim_reverse" } ) assert_routing( - { :path => "/geocoder/description_osm_nominatim", :method => :get }, - { :controller => "geocoder", :action => "description_osm_nominatim" } - ) - assert_routing( - { :path => "/geocoder/description_geonames", :method => :get }, - { :controller => "geocoder", :action => "description_geonames" } + { :path => "/geocoder/search_geonames_reverse", :method => :get }, + { :controller => "geocoder", :action => "search_geonames_reverse" } ) end @@ -69,8 +52,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal code, assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -85,8 +70,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "50.06773, 14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -101,8 +88,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "50.06773, -14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta -14.37742, @controller.params[:lon] end end @@ -117,8 +106,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "-50.06773, 14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta -50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -133,8 +124,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "-50.06773, -14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta -50.06773, @controller.params[:lat] + assert_in_delta -14.37742, @controller.params[:lon] end end @@ -152,8 +145,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_latlon_equal_round "50.06773, 14.37742", assigns(:query), 5 + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -171,8 +166,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_latlon_equal_round "50.06773, -14.37742", assigns(:query), 5 + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta -14.37742, @controller.params[:lon] end end @@ -190,8 +187,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_latlon_equal_round "-50.06773, 14.37742", assigns(:query), 5 + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta -50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -209,8 +208,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_latlon_equal_round "-50.06773, -14.37742", assigns(:query), 5 + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta -50.06773, @controller.params[:lat] + assert_in_delta -14.37742, @controller.params[:lon] end end @@ -227,8 +228,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "50.06773, 14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -245,8 +248,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "50.06773, -14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta 50.06773, @controller.params[:lat] + assert_in_delta -14.37742, @controller.params[:lon] end end @@ -263,8 +268,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "-50.06773, 14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta -50.06773, @controller.params[:lat] + assert_in_delta 14.37742, @controller.params[:lon] end end @@ -281,8 +288,10 @@ class GeocoderControllerTest < ActionController::TestCase ].each do |code| post :search, :query => code assert_response :success - assert_equal ['latlon'], assigns(:sources) - assert_equal "-50.06773, -14.37742", assigns(:query) + assert_equal ['osm_nominatim_reverse', 'geonames_reverse'], assigns(:sources) + assert_nil @controller.params[:query] + assert_in_delta -50.06773, @controller.params[:lat] + assert_in_delta -14.37742, @controller.params[:lon] end end @@ -332,13 +341,4 @@ class GeocoderControllerTest < ActionController::TestCase assert_response :success assert_equal ['osm_nominatim'], assigns(:sources) end - -private - - ## - # this is a test helper for rounding latlon strings to a specified precision, e.g., at a precision - # of 5, "50.06773333333334, -14.377416666666667" will become "50.06773, -14.37742" - def assert_latlon_equal_round(expected, actual, precision) - assert_equal expected.split(',').map {|i| i.to_f.round(precision)}.join(', '), actual.split(',').map {|i| i.to_f.round(precision)}.join(', ') - end end