]> git.openstreetmap.org Git - rails.git/blob - test/lib/osm_test.rb
Merge pull request #7302 from tomhughes/terms-locale
[rails.git] / test / lib / osm_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 class OsmTest < ActiveSupport::TestCase
6   def test_mercator
7     proj = OSM::Mercator.new(0, 0, 1, 1, 100, 200)
8     assert_in_delta(50, proj.x(0.5), 0.01)
9     assert_in_delta(100, proj.y(0.5), 0.01)
10   end
11
12   def test_mercator_collapsed_bbox
13     proj = OSM::Mercator.new(0, 0, 0, 0, 100, 200)
14     assert_in_delta(50, proj.x(0), 0.01)
15     assert_in_delta(100, proj.y(0), 0.01)
16   end
17
18   def test_legal_text_for_country
19     OSM::LEGALES.each do |legale|
20       text = OSM.legal_text_for_country(legale)
21
22       assert_predicate text["intro"], :html_safe?
23     end
24   end
25
26   def test_legal_text_for_unknown_country
27     default_text = OSM.legal_text_for_country(Settings.default_legale)
28
29     ["ZZ", "..", "../../config/settings", "/etc/passwd", "GB\n../../config/settings", nil]
30       .each do |legale|
31       assert_equal default_text, OSM.legal_text_for_country(legale)
32     end
33   end
34 end