1 require "application_system_test_case"
3 class SearchTest < ApplicationSystemTestCase
4 test "click on 'where is this' sets search input value" do
5 stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
6 .to_return(:status => 404)
8 visit "/#map=7/1.234/6.789"
10 assert_field "Search", :with => ""
11 click_on "Where is this?"
12 assert_field "Search", :with => "1.234, 6.789"
15 test "query search link sets search input value" do
16 stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
17 .to_return(:status => 404)
19 visit search_path(:query => "2.341, 7.896")
21 assert_field "Search", :with => "2.341, 7.896"
24 test "latlon search link sets search input value" do
25 stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
26 .to_return(:status => 404)
28 visit search_path(:lat => "4.321", :lon => "9.876")
30 assert_field "Search", :with => "4.321, 9.876"
33 test "search adds viewbox param to Nominatim link" do
34 stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/search\?})
35 .to_return(:status => 404)
39 fill_in "query", :with => "paris"
42 assert_link "OpenStreetMap Nominatim", :href => /&viewbox=/
45 test "search adds zoom param to reverse Nominatim link" do
46 stub_request(:get, %r{^https://nominatim\.openstreetmap\.org/reverse\?})
47 .to_return(:status => 404)
49 visit "/#map=7/1.234/6.789"
51 fill_in "query", :with => "60 30"
54 assert_link "OpenStreetMap Nominatim", :href => /&zoom=7/