]> git.openstreetmap.org Git - rails.git/blob - test/controllers/searches/nominatim_queries_controller_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / controllers / searches / nominatim_queries_controller_test.rb
1 require_relative "queries_controller_test"
2
3 module Searches
4   class NominatimQueriesControllerTest < QueriesControllerTest
5     ##
6     # test all routes which lead to this controller
7     def test_routes
8       assert_routing(
9         { :path => "/search/nominatim_query", :method => :post },
10         { :controller => "searches/nominatim_queries", :action => "create" }
11       )
12     end
13
14     def test_create
15       with_http_stubs "nominatim" do
16         post search_nominatim_query_path(:query => "Hoddesdon", :zoom => 10,
17                                          :minlon => -0.559, :minlat => 51.217,
18                                          :maxlon => 0.836, :maxlat => 51.766), :xhr => true
19         results_check "name" => "Hoddesdon, Hertfordshire, East of England, England, United Kingdom",
20                       "min-lat" => 51.7216709, "max-lat" => 51.8016709,
21                       "min-lon" => -0.0512898, "max-lon" => 0.0287102,
22                       "type" => "node", "id" => 18007599
23
24         post search_nominatim_query_path(:query => "Broxbourne", :zoom => 10,
25                                          :minlon => -0.559, :minlat => 51.217,
26                                          :maxlon => 0.836, :maxlat => 51.766), :xhr => true
27         results_check({ "prefix" => "Suburb",
28                         "name" => "Broxbourne, Hertfordshire, East of England, England, United Kingdom",
29                         "min-lat" => 51.7265723, "max-lat" => 51.7665723,
30                         "min-lon" => -0.0390782, "max-lon" => 0.0009218,
31                         "type" => "node", "id" => 28825933 },
32                       { "prefix" => "Village",
33                         "name" => "Broxbourne, Hertfordshire, East of England, England, United Kingdom",
34                         "min-lat" => 51.6808751, "max-lat" => 51.7806237,
35                         "min-lon" => -0.114204, "max-lon" => 0.0145267,
36                         "type" => "relation", "id" => 2677978 },
37                       { "prefix" => "Railway Station",
38                         "name" => "Broxbourne, Stafford Drive, Broxbourne, Hertfordshire, East of England, England, United Kingdom",
39                         "min-lat" => 51.7418469, "max-lat" => 51.7518469,
40                         "min-lon" => -0.0156773, "max-lon" => -0.0056773,
41                         "type" => "node", "id" => 17044599 })
42       end
43     end
44   end
45 end