]> git.openstreetmap.org Git - rails.git/blobdiff - test/helpers/browse_tags_helper_test.rb
Avoid converting conditional restriction tags into emails
[rails.git] / test / helpers / browse_tags_helper_test.rb
index 3aa851ef9e3fc169e1205d1681a3fba0b52e7612..f9f977c4986026206e433f480002fb74c34d5312 100644 (file)
@@ -22,6 +22,9 @@ class BrowseTagsHelperTest < ActionView::TestCase
     html = format_value("unknown", "unknown")
     assert_dom_equal "unknown", html
 
+    html = format_value("addr:street", "Rue de l'Amigo")
+    assert_dom_equal "Rue de l&#39;Amigo", html
+
     html = format_value("phone", "+1234567890")
     assert_dom_equal "<a href=\"tel:+1234567890\" title=\"Call +1234567890\">+1234567890</a>", html
 
@@ -46,6 +49,15 @@ class BrowseTagsHelperTest < ActionView::TestCase
 
     html = format_value("colour", "#f00")
     assert_dom_equal %(<span class="colour-preview-box" data-colour="#f00" title="Colour #f00 preview"></span>#f00), html
+
+    html = format_value("email", "foo@example.com")
+    assert_dom_equal "<a title=\"Email foo@example.com\" href=\"mailto:foo@example.com\">foo@example.com</a>", html
+
+    html = format_value("source", "https://example.com")
+    assert_dom_equal "<a href=\"https://example.com\" rel=\"nofollow\">https://example.com</a>", html
+
+    html = format_value("source", "https://example.com;hello;https://example.net")
+    assert_dom_equal "<a href=\"https://example.com\" rel=\"nofollow\">https://example.com</a>;hello;<a href=\"https://example.net\" rel=\"nofollow\">https://example.net</a>", html
   end
 
   def test_wiki_link
@@ -169,11 +181,11 @@ class BrowseTagsHelperTest < ActionView::TestCase
     assert_equal "de:Englischer Garten (München)#Japanisches Teehaus", link[:title]
 
     link = wikipedia_link("wikipedia", "de:Alte Brücke (Heidelberg)#Brückenaffe")
-    assert_equal "https://de.wikipedia.org/wiki/de:Alte Brücke (Heidelberg)?uselang=en#Br.C3.BCckenaffe", link[:url]
+    assert_equal "https://de.wikipedia.org/wiki/de:Alte Brücke (Heidelberg)?uselang=en#Br%C3%BCckenaffe", link[:url]
     assert_equal "de:Alte Brücke (Heidelberg)#Brückenaffe", link[:title]
 
     link = wikipedia_link("wikipedia", "de:Liste der Baudenkmäler in Eichstätt#Brückenstraße 1, Ehemaliges Bauernhaus")
-    assert_equal "https://de.wikipedia.org/wiki/de:Liste der Baudenkmäler in Eichstätt?uselang=en#Br.C3.BCckenstra.C3.9Fe_1.2C_Ehemaliges_Bauernhaus", link[:url]
+    assert_equal "https://de.wikipedia.org/wiki/de:Liste der Baudenkmäler in Eichstätt?uselang=en#Br%C3%BCckenstra%C3%9Fe_1%2C_Ehemaliges_Bauernhaus", link[:url]
     assert_equal "de:Liste der Baudenkmäler in Eichstätt#Brückenstraße 1, Ehemaliges Bauernhaus", link[:title]
 
     I18n.with_locale "pt-BR" do
@@ -240,29 +252,29 @@ class BrowseTagsHelperTest < ActionView::TestCase
     assert_nil email
 
     email = email_link("email", "x@example.com")
-    assert_equal "x@example.com", email[:email]
-    assert_equal "mailto:x@example.com", email[:url]
+    assert_equal "x@example.com", email
 
     email = email_link("email", "other.email-with-hyphen@example.com")
-    assert_equal "other.email-with-hyphen@example.com", email[:email]
-    assert_equal "mailto:other.email-with-hyphen@example.com", email[:url]
+    assert_equal "other.email-with-hyphen@example.com", email
 
     email = email_link("email", "user.name+tag+sorting@example.com")
-    assert_equal "user.name+tag+sorting@example.com", email[:email]
-    assert_equal "mailto:user.name+tag+sorting@example.com", email[:url]
+    assert_equal "user.name+tag+sorting@example.com", email
 
     email = email_link("email", "dash-in@both-parts.com")
-    assert_equal "dash-in@both-parts.com", email[:email]
-    assert_equal "mailto:dash-in@both-parts.com", email[:url]
+    assert_equal "dash-in@both-parts.com", email
 
     email = email_link("email", "example@s.example")
-    assert_equal "example@s.example", email[:email]
-    assert_equal "mailto:example@s.example", email[:url]
+    assert_equal "example@s.example", email
 
     # Strips whitespace at ends
     email = email_link("email", " test@email.com ")
-    assert_equal "test@email.com", email[:email]
-    assert_equal "mailto:test@email.com", email[:url]
+    assert_equal "test@email.com", email
+
+    email = email_link("contact:email", "example@example.com")
+    assert_equal "example@example.com", email
+
+    email = email_link("maxweight:conditional", "none@agricultural")
+    assert_nil email
   end
 
   def test_telephone_links