]> git.openstreetmap.org Git - rails.git/blobdiff - test/helpers/browse_tags_helper_test.rb
Merge pull request #2409 from jalessio/docker-compose-take2
[rails.git] / test / helpers / browse_tags_helper_test.rb
index 3239f22116c471bb6dafd5118863238a640cf1cc..5574513c25ded332c2c7ff9c9da64a7449daeeed 100644 (file)
@@ -43,7 +43,8 @@ class BrowseTagsHelperTest < ActionView::TestCase
     assert_dom_equal "<a title=\"The Q42 item on Wikidata\" href=\"//www.wikidata.org/entity/Q42?uselang=en\">Q42</a>", html
 
     html = format_value("operator:wikidata", "Q12;Q98")
-    assert_dom_equal "<a title=\"The Q12 item on Wikidata\" href=\"//www.wikidata.org/entity/Q12?uselang=en\">Q12</a>;<a title=\"The Q98 item on Wikidata\" href=\"//www.wikidata.org/entity/Q98?uselang=en\">Q98</a>", html
+    assert_dom_equal "<a title=\"The Q12 item on Wikidata\" href=\"//www.wikidata.org/entity/Q12?uselang=en\">Q12</a>;" \
+                     "<a title=\"The Q98 item on Wikidata\" href=\"//www.wikidata.org/entity/Q98?uselang=en\">Q98</a>", html
 
     html = format_value("name:etymology:wikidata", "Q123")
     assert_dom_equal "<a title=\"The Q123 item on Wikidata\" href=\"//www.wikidata.org/entity/Q123?uselang=en\">Q123</a>", html
@@ -221,76 +222,55 @@ class BrowseTagsHelperTest < ActionView::TestCase
     assert_nil link
   end
 
-  def test_email_links
-    links = email_links("foo", "Test")
-    assert_nil links
+  def test_email_link
+    email = email_link("foo", "Test")
+    assert_nil email
 
-    links = email_links("email", "123")
-    assert_nil links
+    email = email_link("email", "123")
+    assert_nil email
 
-    links = email_links("email", "Abc.example.com")
-    assert_nil links
+    email = email_link("email", "Abc.example.com")
+    assert_nil email
 
-    links = email_links("email", "a@b@c.com")
-    assert_nil links
+    email = email_link("email", "a@b@c.com")
+    assert_nil email
 
-    links = email_links("email", "123 abcdefg@space.com")
-    assert_nil links
+    email = email_link("email", "just\"not\"right@example.com")
+    assert_nil email
 
-    links = email_links("email", "test@ abc")
-    assert_nil links
+    email = email_link("email", "123 abcdefg@space.com")
+    assert_nil email
 
-    links = email_links("email", "just\"not\"right@example.com")
-    assert_nil links
+    email = email_link("email", "test@ abc")
+    assert_nil email
 
-    # If multiple emails are listed, all must be valid
-    links = email_links("email", "very.common@test.com; a@b@c.com")
-    assert_nil links
+    email = email_link("email", "using;semicolon@test.com")
+    assert_nil email
 
-    links = email_links("email", "x@example.com")
-    assert_equal 1, links.length
-    assert_equal "x@example.com", links[0][:email]
-    assert_equal "mailto:x@example.com", links[0][:url]
+    email = email_link("email", "x@example.com")
+    assert_equal "x@example.com", email[:email]
+    assert_equal "mailto:x@example.com", email[:url]
 
-    links = email_links("email", "other.email-with-hyphen@example.com")
-    assert_equal 1, links.length
-    assert_equal "other.email-with-hyphen@example.com", links[0][:email]
-    assert_equal "mailto:other.email-with-hyphen@example.com", links[0][:url]
+    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]
 
-    links = email_links("email", "user.name+tag+sorting@example.com")
-    assert_equal 1, links.length
-    assert_equal "user.name+tag+sorting@example.com", links[0][:email]
-    assert_equal "mailto:user.name+tag+sorting@example.com", links[0][:url]
+    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]
 
-    links = email_links("email", "dash-in@both-parts.com")
-    assert_equal 1, links.length
-    assert_equal "dash-in@both-parts.com", links[0][:email]
-    assert_equal "mailto:dash-in@both-parts.com", links[0][:url]
+    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]
 
-    links = email_links("email", "   test@email.com    ")
-    assert_equal 1, links.length
-    assert_equal "test@email.com", links[0][:email]
-    assert_equal "mailto:test@email.com", links[0][:url]
-
-    links = email_links("email", "example@s.example")
-    assert_equal 1, links.length
-    assert_equal "example@s.example", links[0][:email]
-    assert_equal "mailto:example@s.example", links[0][:url]
+    email = email_link("email", "example@s.example")
+    assert_equal "example@s.example", email[:email]
+    assert_equal "mailto:example@s.example", email[:url]
 
-    # Multiple valid phone numbers separated by ;
-    links = email_links("email", "test@email.com; example@s.example")
-    assert_equal 2, links.length
-    assert_equal "test@email.com", links[0][:email]
-    assert_equal "mailto:test@email.com", links[0][:url]
-    assert_equal "example@s.example", links[1][:email]
-    assert_equal "mailto:example@s.example", links[1][:url]
-
-    links = email_links("email", "x@example.com ;  dash-in@both-parts.com ")
-    assert_equal 2, links.length
-    assert_equal "x@example.com", links[0][:email]
-    assert_equal "mailto:x@example.com", links[0][:url]
-    assert_equal "dash-in@both-parts.com", links[1][:email]
-    assert_equal "mailto:dash-in@both-parts.com", links[1][:url]
+    # 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]
   end
 
   def test_telephone_links