]> git.openstreetmap.org Git - rails.git/blob - test/controllers/searches/latlon_queries_controller_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / controllers / searches / latlon_queries_controller_test.rb
1 require_relative "queries_controller_test"
2
3 module Searches
4   class LatlonQueriesControllerTest < QueriesControllerTest
5     ##
6     # test all routes which lead to this controller
7     def test_routes
8       assert_routing(
9         { :path => "/search/latlon_query", :method => :post },
10         { :controller => "searches/latlon_queries", :action => "create" }
11       )
12     end
13
14     def test_create
15       post search_latlon_query_path(:lat => 1.23, :lon => 4.56, :zoom => 16), :xhr => true
16       results_check :name => "1.23, 4.56", :lat => 1.23, :lon => 4.56, :zoom => 16
17
18       post search_latlon_query_path(:lat => -91.23, :lon => 4.56, :zoom => 16), :xhr => true
19       results_check_error "Latitude -91.23 out of range"
20
21       post search_latlon_query_path(:lat => 91.23, :lon => 4.56, :zoom => 16), :xhr => true
22       results_check_error "Latitude 91.23 out of range"
23
24       post search_latlon_query_path(:lat => 1.23, :lon => -180.23, :zoom => 16), :xhr => true
25       results_check_error "Longitude -180.23 out of range"
26
27       post search_latlon_query_path(:lat => 1.23, :lon => 180.23, :zoom => 16), :xhr => true
28       results_check_error "Longitude 180.23 out of range"
29     end
30
31     def test_create_digits
32       post search_latlon_query_path(:lat => 1.23, :lon => 4.56, :zoom => 16, :latlon_digits => true), :xhr => true
33       results_check({ :name => "1.23, 4.56", :lat => 1.23, :lon => 4.56, :zoom => 16 },
34                     { :name => "4.56, 1.23", :lat => 4.56, :lon => 1.23, :zoom => 16 })
35
36       post search_latlon_query_path(:lat => -91.23, :lon => 4.56, :zoom => 16, :latlon_digits => true), :xhr => true
37       results_check :name => "4.56, -91.23", :lat => 4.56, :lon => -91.23, :zoom => 16
38
39       post search_latlon_query_path(:lat => -1.23, :lon => 170.23, :zoom => 16, :latlon_digits => true), :xhr => true
40       results_check :name => "-1.23, 170.23", :lat => -1.23, :lon => 170.23, :zoom => 16
41
42       post search_latlon_query_path(:lat => 91.23, :lon => 94.56, :zoom => 16, :latlon_digits => true), :xhr => true
43       results_check_error "Latitude or longitude are out of range"
44
45       post search_latlon_query_path(:lat => -91.23, :lon => -94.56, :zoom => 16, :latlon_digits => true), :xhr => true
46       results_check_error "Latitude or longitude are out of range"
47
48       post search_latlon_query_path(:lat => 1.23, :lon => -180.23, :zoom => 16, :latlon_digits => true), :xhr => true
49       results_check_error "Latitude or longitude are out of range"
50
51       post search_latlon_query_path(:lat => 1.23, :lon => 180.23, :zoom => 16, :latlon_digits => true), :xhr => true
52       results_check_error "Latitude or longitude are out of range"
53     end
54   end
55 end