X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/902ba27de98506448a550e81f58ce7b845ee183b..58353508796310d8a65c949095e7a93a7065dbb1:/test/functional/geocoder_controller_test.rb?ds=inline diff --git a/test/functional/geocoder_controller_test.rb b/test/functional/geocoder_controller_test.rb index 6d1d1f1c5..d8eee97d8 100644 --- a/test/functional/geocoder_controller_test.rb +++ b/test/functional/geocoder_controller_test.rb @@ -12,8 +12,8 @@ class GeocoderControllerTest < ActionController::TestCase { :controller => "geocoder", :action => "search" } ) assert_routing( - { :path => "/geocoder/search_latlon", :method => :get }, - { :controller => "geocoder", :action => "search_latlon" } + { :path => "/geocoder/search_latlon", :method => :get }, + { :controller => "geocoder", :action => "search_latlon" } ) assert_routing( { :path => "/geocoder/search_us_postcode", :method => :get }, @@ -27,10 +27,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 +35,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 +56,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 ['latlon' ,'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 +74,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 ['latlon' ,'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 +92,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 ['latlon' ,'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 +110,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 ['latlon' ,'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 +128,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 ['latlon' ,'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 +149,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 ['latlon' ,'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 +170,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 ['latlon' ,'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 +191,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 ['latlon' ,'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 +212,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 ['latlon' ,'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 +232,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 ['latlon' ,'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 +252,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 ['latlon' ,'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 +272,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 ['latlon' ,'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 +292,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 ['latlon' ,'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 +345,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