From: Florian M. Schäfer Date: Sun, 20 Jul 2014 05:35:36 +0000 (+0200) Subject: Added tests for wikidata links in the browse helper X-Git-Tag: live~4900 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/212e7153d8cc5a82614ef414dd963f959dd3b1a7?hp=7764f6fc28610799b09ea62e48189aa51e341e41 Added tests for wikidata links in the browse helper --- diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index d5f7a91e6..7bc731a0c 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -132,6 +132,33 @@ class BrowseHelperTest < ActionView::TestCase assert_equal "http://wiki.openstreetmap.org/wiki/Tag:highway=primary?uselang=tr", link end + def test_wikidata_link + link = wikidata_link("foo", "Test") + assert_nil link + + link = wikidata_link("wikidata", "http://www.wikidata.org/wiki/Q1") + assert_nil link + + link = wikidata_link("wikidata", "en:Q1") + assert_nil link + + link = wikidata_link("wikidata", "1") + assert_nil link + + link = wikidata_link("wikidata", "Q0123") + assert_nil link + + link = wikidata_link("wikidata", "Q42") + assert_equal "//www.wikidata.org/wiki/Q42?uselang=en", link[:url] + assert_equal "Q42", link[:title] + + I18n.locale = "zh-CN" + + link = wikidata_link("wikidata", "Q1234") + assert_equal "//www.wikidata.org/wiki/Q1234?uselang=zh-CN", link[:url] + assert_equal "Q1234", link[:title] + end + def test_wikipedia_link link = wikipedia_link("wikipedia", "http://en.wikipedia.org/wiki/Full%20URL") assert_nil link