From 212e7153d8cc5a82614ef414dd963f959dd3b1a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Florian=20M=2E=20Sch=C3=A4fer?= Date: Sun, 20 Jul 2014 07:35:36 +0200 Subject: [PATCH 1/1] Added tests for wikidata links in the browse helper --- test/helpers/browse_helper_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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 -- 2.39.5