1 # frozen_string_literal: true
3 require_relative "queries_controller_test"
6 class LatlonQueriesControllerTest < QueriesControllerTest
8 # test all routes which lead to this controller
11 { :path => "/search/latlon_query", :method => :post },
12 { :controller => "searches/latlon_queries", :action => "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
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"
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"
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"
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"
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 })
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
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
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"
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"
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"
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"