Fix new ruboop warnings
This commit is contained in:
parent
449b2b869a
commit
63e4a89323
5 changed files with 71 additions and 107 deletions
|
@ -3,14 +3,6 @@ require "test_helper"
|
||||||
class ApplicationHelperTest < ActionView::TestCase
|
class ApplicationHelperTest < ActionView::TestCase
|
||||||
attr_accessor :current_user
|
attr_accessor :current_user
|
||||||
|
|
||||||
def setup
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_linkify
|
def test_linkify
|
||||||
%w[http://example.com/test ftp://example.com/test https://example.com/test].each do |link|
|
%w[http://example.com/test ftp://example.com/test https://example.com/test].each do |link|
|
||||||
text = "Test #{link} is <b>made</b> into a link"
|
text = "Test #{link} is <b>made</b> into a link"
|
||||||
|
@ -54,13 +46,13 @@ class ApplicationHelperTest < ActionView::TestCase
|
||||||
assert_equal "rtl", dir
|
assert_equal "rtl", dir
|
||||||
params.delete(:dir)
|
params.delete(:dir)
|
||||||
|
|
||||||
I18n.locale = "he"
|
I18n.with_locale "he" do
|
||||||
|
assert_equal "rtl", dir
|
||||||
|
|
||||||
assert_equal "rtl", dir
|
params[:dir] = "ltr"
|
||||||
|
assert_equal "ltr", dir
|
||||||
params[:dir] = "ltr"
|
params.delete(:dir)
|
||||||
assert_equal "ltr", dir
|
end
|
||||||
params.delete(:dir)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_friendly_date
|
def test_friendly_date
|
||||||
|
|
|
@ -4,14 +4,6 @@ class BrowseHelperTest < ActionView::TestCase
|
||||||
include ERB::Util
|
include ERB::Util
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def setup
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_printable_name
|
def test_printable_name
|
||||||
node = create(:node, :with_history, :version => 2)
|
node = create(:node, :with_history, :version => 2)
|
||||||
node_v1 = node.old_nodes.find_by(:version => 1)
|
node_v1 = node.old_nodes.find_by(:version => 1)
|
||||||
|
@ -35,35 +27,35 @@ class BrowseHelperTest < ActionView::TestCase
|
||||||
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
||||||
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
||||||
|
|
||||||
I18n.locale = "pt"
|
I18n.with_locale "pt" do
|
||||||
|
assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
|
||||||
|
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
|
||||||
|
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
|
||||||
|
assert_dom_equal node.id.to_s, printable_name(node_v1)
|
||||||
|
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
|
||||||
|
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
||||||
|
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
||||||
|
end
|
||||||
|
|
||||||
assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
|
I18n.with_locale "pt-BR" do
|
||||||
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
|
assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
|
||||||
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
|
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
|
||||||
assert_dom_equal node.id.to_s, printable_name(node_v1)
|
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
|
||||||
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
|
assert_dom_equal node.id.to_s, printable_name(node_v1)
|
||||||
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
|
||||||
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
||||||
|
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
||||||
|
end
|
||||||
|
|
||||||
I18n.locale = "pt-BR"
|
I18n.with_locale "de" do
|
||||||
|
assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
|
||||||
assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
|
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
|
||||||
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
|
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
|
||||||
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
|
assert_dom_equal node.id.to_s, printable_name(node_v1)
|
||||||
assert_dom_equal node.id.to_s, printable_name(node_v1)
|
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
|
||||||
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
|
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
||||||
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
||||||
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
end
|
||||||
|
|
||||||
I18n.locale = "de"
|
|
||||||
|
|
||||||
assert_dom_equal deleted_node.id.to_s, printable_name(deleted_node)
|
|
||||||
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
|
|
||||||
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
|
|
||||||
assert_dom_equal node.id.to_s, printable_name(node_v1)
|
|
||||||
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
|
|
||||||
assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
|
|
||||||
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_class
|
def test_link_class
|
||||||
|
|
|
@ -4,14 +4,6 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
||||||
include ERB::Util
|
include ERB::Util
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def setup
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_format_key
|
def test_format_key
|
||||||
html = format_key("highway")
|
html = format_key("highway")
|
||||||
assert_dom_equal "<a href=\"https://wiki.openstreetmap.org/wiki/Key:highway?uselang=en\" title=\"The wiki description page for the highway tag\">highway</a>", html
|
assert_dom_equal "<a href=\"https://wiki.openstreetmap.org/wiki/Key:highway?uselang=en\" title=\"The wiki description page for the highway tag\">highway</a>", html
|
||||||
|
@ -63,21 +55,21 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
||||||
link = wiki_link("tag", "highway=primary")
|
link = wiki_link("tag", "highway=primary")
|
||||||
assert_equal "https://wiki.openstreetmap.org/wiki/Tag:highway=primary?uselang=en", link
|
assert_equal "https://wiki.openstreetmap.org/wiki/Tag:highway=primary?uselang=en", link
|
||||||
|
|
||||||
I18n.locale = "de"
|
I18n.with_locale "de" do
|
||||||
|
link = wiki_link("key", "highway")
|
||||||
|
assert_equal "https://wiki.openstreetmap.org/wiki/DE:Key:highway?uselang=de", link
|
||||||
|
|
||||||
link = wiki_link("key", "highway")
|
link = wiki_link("tag", "highway=primary")
|
||||||
assert_equal "https://wiki.openstreetmap.org/wiki/DE:Key:highway?uselang=de", link
|
assert_equal "https://wiki.openstreetmap.org/wiki/DE:Tag:highway=primary?uselang=de", link
|
||||||
|
end
|
||||||
|
|
||||||
link = wiki_link("tag", "highway=primary")
|
I18n.with_locale "tr" do
|
||||||
assert_equal "https://wiki.openstreetmap.org/wiki/DE:Tag:highway=primary?uselang=de", link
|
link = wiki_link("key", "highway")
|
||||||
|
assert_equal "https://wiki.openstreetmap.org/wiki/Tr:Key:highway?uselang=tr", link
|
||||||
|
|
||||||
I18n.locale = "tr"
|
link = wiki_link("tag", "highway=primary")
|
||||||
|
assert_equal "https://wiki.openstreetmap.org/wiki/Tag:highway=primary?uselang=tr", link
|
||||||
link = wiki_link("key", "highway")
|
end
|
||||||
assert_equal "https://wiki.openstreetmap.org/wiki/Tr:Key:highway?uselang=tr", link
|
|
||||||
|
|
||||||
link = wiki_link("tag", "highway=primary")
|
|
||||||
assert_equal "https://wiki.openstreetmap.org/wiki/Tag:highway=primary?uselang=tr", link
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_wikidata_links
|
def test_wikidata_links
|
||||||
|
@ -110,12 +102,12 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
||||||
assert_equal "Q42", links[0][:title]
|
assert_equal "Q42", links[0][:title]
|
||||||
|
|
||||||
# the language of the wikidata-page should match the current locale
|
# the language of the wikidata-page should match the current locale
|
||||||
I18n.locale = "zh-CN"
|
I18n.with_locale "zh-CN" do
|
||||||
links = wikidata_links("wikidata", "Q1234")
|
links = wikidata_links("wikidata", "Q1234")
|
||||||
assert_equal 1, links.length
|
assert_equal 1, links.length
|
||||||
assert_equal "//www.wikidata.org/entity/Q1234?uselang=zh-CN", links[0][:url]
|
assert_equal "//www.wikidata.org/entity/Q1234?uselang=zh-CN", links[0][:url]
|
||||||
assert_equal "Q1234", links[0][:title]
|
assert_equal "Q1234", links[0][:title]
|
||||||
I18n.locale = "en"
|
end
|
||||||
|
|
||||||
### Prefixed wikidata-tags
|
### Prefixed wikidata-tags
|
||||||
|
|
||||||
|
@ -129,16 +121,16 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
||||||
assert_equal "Q24", links[0][:title]
|
assert_equal "Q24", links[0][:title]
|
||||||
|
|
||||||
# Another allowed key, this time with multiple values and I18n
|
# Another allowed key, this time with multiple values and I18n
|
||||||
I18n.locale = "dsb"
|
I18n.with_locale "dsb" do
|
||||||
links = wikidata_links("brand:wikidata", "Q936;Q2013;Q1568346")
|
links = wikidata_links("brand:wikidata", "Q936;Q2013;Q1568346")
|
||||||
assert_equal 3, links.length
|
assert_equal 3, links.length
|
||||||
assert_equal "//www.wikidata.org/entity/Q936?uselang=dsb", links[0][:url]
|
assert_equal "//www.wikidata.org/entity/Q936?uselang=dsb", links[0][:url]
|
||||||
assert_equal "Q936", links[0][:title]
|
assert_equal "Q936", links[0][:title]
|
||||||
assert_equal "//www.wikidata.org/entity/Q2013?uselang=dsb", links[1][:url]
|
assert_equal "//www.wikidata.org/entity/Q2013?uselang=dsb", links[1][:url]
|
||||||
assert_equal "Q2013", links[1][:title]
|
assert_equal "Q2013", links[1][:title]
|
||||||
assert_equal "//www.wikidata.org/entity/Q1568346?uselang=dsb", links[2][:url]
|
assert_equal "//www.wikidata.org/entity/Q1568346?uselang=dsb", links[2][:url]
|
||||||
assert_equal "Q1568346", links[2][:title]
|
assert_equal "Q1568346", links[2][:title]
|
||||||
I18n.locale = "en"
|
end
|
||||||
|
|
||||||
# and now with whitespaces...
|
# and now with whitespaces...
|
||||||
links = wikidata_links("subject:wikidata", "Q6542248 ;\tQ180\n ;\rQ364\t\n\r ;\nQ4006")
|
links = wikidata_links("subject:wikidata", "Q6542248 ;\tQ180\n ;\rQ364\t\n\r ;\nQ4006")
|
||||||
|
@ -184,11 +176,11 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
||||||
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]
|
assert_equal "de:Liste der Baudenkmäler in Eichstätt#Brückenstraße 1, Ehemaliges Bauernhaus", link[:title]
|
||||||
|
|
||||||
I18n.locale = "pt-BR"
|
I18n.with_locale "pt-BR" do
|
||||||
|
link = wikipedia_link("wikipedia", "zh-classical:Test#Section")
|
||||||
link = wikipedia_link("wikipedia", "zh-classical:Test#Section")
|
assert_equal "https://zh-classical.wikipedia.org/wiki/zh-classical:Test?uselang=pt-BR#Section", link[:url]
|
||||||
assert_equal "https://zh-classical.wikipedia.org/wiki/zh-classical:Test?uselang=pt-BR#Section", link[:url]
|
assert_equal "zh-classical:Test#Section", link[:title]
|
||||||
assert_equal "zh-classical:Test#Section", link[:title]
|
end
|
||||||
|
|
||||||
link = wikipedia_link("foo", "Test")
|
link = wikipedia_link("foo", "Test")
|
||||||
assert_nil link
|
assert_nil link
|
||||||
|
@ -212,11 +204,11 @@ class BrowseTagsHelperTest < ActionView::TestCase
|
||||||
assert_equal "//commons.wikimedia.org/wiki/Category:Test_Category?uselang=en", link[:url]
|
assert_equal "//commons.wikimedia.org/wiki/Category:Test_Category?uselang=en", link[:url]
|
||||||
assert_equal "Category:Test_Category", link[:title]
|
assert_equal "Category:Test_Category", link[:title]
|
||||||
|
|
||||||
I18n.locale = "pt-BR"
|
I18n.with_locale "pt-BR" do
|
||||||
|
link = wikimedia_commons_link("wikimedia_commons", "File:Test.jpg")
|
||||||
link = wikimedia_commons_link("wikimedia_commons", "File:Test.jpg")
|
assert_equal "//commons.wikimedia.org/wiki/File:Test.jpg?uselang=pt-BR", link[:url]
|
||||||
assert_equal "//commons.wikimedia.org/wiki/File:Test.jpg?uselang=pt-BR", link[:url]
|
assert_equal "File:Test.jpg", link[:title]
|
||||||
assert_equal "File:Test.jpg", link[:title]
|
end
|
||||||
|
|
||||||
link = wikimedia_commons_link("foo", "Test")
|
link = wikimedia_commons_link("foo", "Test")
|
||||||
assert_nil link
|
assert_nil link
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class PageLocaleTest < ActionDispatch::IntegrationTest
|
class PageLocaleTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
I18n.locale = "en"
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_defaulting
|
def test_defaulting
|
||||||
user = create(:user, :languages => [])
|
user = create(:user, :languages => [])
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,12 @@ require "test_helper"
|
||||||
|
|
||||||
class UserCreationTest < ActionDispatch::IntegrationTest
|
class UserCreationTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
I18n.locale = "en"
|
|
||||||
|
|
||||||
OmniAuth.config.test_mode = true
|
OmniAuth.config.test_mode = true
|
||||||
|
|
||||||
stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
|
stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
I18n.locale = "en"
|
|
||||||
|
|
||||||
OmniAuth.config.mock_auth[:openid] = nil
|
OmniAuth.config.mock_auth[:openid] = nil
|
||||||
OmniAuth.config.mock_auth[:google] = nil
|
OmniAuth.config.mock_auth[:google] = nil
|
||||||
OmniAuth.config.mock_auth[:facebook] = nil
|
OmniAuth.config.mock_auth[:facebook] = nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue