]> git.openstreetmap.org Git - rails.git/blob - test/lib/nominatim_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / lib / nominatim_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class NominatimTest < ActiveSupport::TestCase
6   def test_describe_location
7     stub_request(:get, %r{^https://nominatim\.example\.com/reverse\?})
8       .to_return(:body => "<reversegeocode><result>Target location</result></reversegeocode>")
9
10     with_settings(:nominatim_url => "https://nominatim.example.com/") do
11       location = Nominatim.describe_location(60, 30, 10, "en")
12       assert_equal "Target location", location
13     end
14
15     assert_requested :get, "https://nominatim.example.com/reverse?lat=60&lon=30&zoom=10&accept-language=en",
16                      :headers => { "User-Agent" => Settings.server_url }
17   end
18
19   def test_describe_location_no_result
20     stub_request(:get, %r{^https://nominatim\.example\.com/reverse\?})
21       .to_return(:body => "<reversegeocode><error>Unable to geocode</error></reversegeocode>")
22
23     with_settings(:nominatim_url => "https://nominatim.example.com/") do
24       location = Nominatim.describe_location(1, 2, 14, "en")
25       assert_equal "1.000, 2.000", location
26     end
27
28     assert_requested :get, "https://nominatim.example.com/reverse?lat=1&lon=2&zoom=14&accept-language=en",
29                      :headers => { "User-Agent" => Settings.server_url }
30   end
31 end