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