wovnrb 0.2.13 → 0.2.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/PULL_REQUEST_TEMPLATE +3 -0
- data/README.md +1 -1
- data/lib/wovnrb/headers.rb +16 -12
- data/lib/wovnrb/html_replacers/image_replacer.rb +8 -2
- data/lib/wovnrb/html_replacers/link_replacer.rb +2 -1
- data/lib/wovnrb/html_replacers/script_replacer.rb +1 -1
- data/lib/wovnrb/lang.rb +13 -9
- data/lib/wovnrb/store.rb +9 -0
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/headers_test.rb +4881 -4805
- data/test/lib/html_replacers/image_replacer_test.rb +17 -8
- data/test/lib/html_replacers/link_replacer_test.rb +27 -0
- data/test/lib/html_replacers/script_replacer_test.rb +18 -2
- data/test/lib/lang_test.rb +49 -9
- data/test/lib/store_test.rb +28 -0
- data/test/lib/wovnrb_test.rb +6 -6
- metadata +4 -4
@@ -69,23 +69,32 @@ module Wovnrb
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_replace_absolute_path
|
72
|
+
img = img_test_helper('/hello/')
|
73
|
+
assert_equal('http://test.com/ttt.img', img.get_attribute('src'))
|
74
|
+
assert_nil(img.previous)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_replace_empty_path
|
78
|
+
img = img_test_helper('')
|
79
|
+
assert_equal('http://test.com/ttt.img', img.get_attribute('src'))
|
80
|
+
assert_nil(img.previous)
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
def img_test_helper path
|
72
85
|
url = {
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:path
|
86
|
+
protocol: 'http',
|
87
|
+
host: 'www.example.com',
|
88
|
+
path: path,
|
76
89
|
}
|
77
90
|
text_index = {}
|
78
91
|
src_index = {
|
79
92
|
'http://www.test.com/test.img' => {'ja' => [{'data' => 'http://test.com/ttt.img'}]}
|
80
93
|
}
|
81
94
|
replacer = ImageReplacer.new(url, text_index, src_index, '')
|
82
|
-
|
83
95
|
dom = Wovnrb.get_dom('<img src="http://www.test.com/test.img"')
|
84
96
|
replacer.replace(dom, Lang.new('ja'))
|
85
|
-
|
86
|
-
img = dom.xpath('//img')[0]
|
87
|
-
assert_equal('http://test.com/ttt.img', img.get_attribute('src'))
|
88
|
-
assert_nil(img.previous)
|
97
|
+
dom.xpath('//img')[0]
|
89
98
|
end
|
90
99
|
end
|
91
100
|
end
|
@@ -33,6 +33,33 @@ module Wovnrb
|
|
33
33
|
assert_equal('/index.html', link)
|
34
34
|
end
|
35
35
|
|
36
|
+
def test_replace_javascript_link_query
|
37
|
+
replacer = LinkReplacer.new('query', get_header)
|
38
|
+
dom = Wovnrb.get_dom('<a href="javascript:void(0);">link text</a>')
|
39
|
+
replacer.replace(dom, Lang.new('en'))
|
40
|
+
|
41
|
+
link = dom.xpath('//a')[0].get_attribute('href')
|
42
|
+
assert_equal('javascript:void(0);', link)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_replace_javascript_link_path
|
46
|
+
replacer = LinkReplacer.new('path', get_header)
|
47
|
+
dom = Wovnrb.get_dom('<a href="javascript:void(0);">link text</a>')
|
48
|
+
replacer.replace(dom, Lang.new('en'))
|
49
|
+
|
50
|
+
link = dom.xpath('//a')[0].get_attribute('href')
|
51
|
+
assert_equal('javascript:void(0);', link)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_replace_javascript_link_subdomain
|
55
|
+
replacer = LinkReplacer.new('subdomain', get_header)
|
56
|
+
dom = Wovnrb.get_dom('<a href="javascript:void(0);">link text</a>')
|
57
|
+
replacer.replace(dom, Lang.new('en'))
|
58
|
+
|
59
|
+
link = dom.xpath('//a')[0].get_attribute('href')
|
60
|
+
assert_equal('javascript:void(0);', link)
|
61
|
+
end
|
62
|
+
|
36
63
|
def test_replace_mustache
|
37
64
|
replacer = LinkReplacer.new('query', get_header)
|
38
65
|
dom = Wovnrb.get_dom('<a href="{{hello}}">link text</a>')
|
@@ -71,11 +71,27 @@ module Wovnrb
|
|
71
71
|
check_wovn_script(scripts[0], 'test_token', 'ja', 'en', 'domain')
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def test_contains_lang_code_aliases
|
75
|
+
store = Store.instance
|
76
|
+
store.settings['user_token'] = 'test_token'
|
77
|
+
store.settings['default_lang'] = 'en'
|
78
|
+
store.settings['url_pattern'] = 'domain'
|
79
|
+
store.settings['custom_lang_aliases'] = {'ja' => 'staging-ja'}
|
80
|
+
|
81
|
+
replacer = ScriptReplacer.new(store)
|
82
|
+
dom = to_head_dom('')
|
83
|
+
replacer.replace(dom, Lang.new('ja'))
|
84
|
+
|
85
|
+
scripts = dom.xpath('//script')
|
86
|
+
assert_equal(1, scripts.length)
|
87
|
+
check_wovn_script(scripts[0], 'test_token', 'ja', 'en', 'domain', '{"ja":"staging-ja"}')
|
88
|
+
end
|
89
|
+
|
90
|
+
def check_wovn_script(node, user_token, current_lang, default_lang, url_pattern, custom_lang_aliases = {})
|
75
91
|
wovn_data = [
|
76
92
|
['src', '//j.wovn.io/1'],
|
77
93
|
['async', 'true'],
|
78
|
-
['data-wovnio', "key=#{user_token}&backend=true¤tLang=#{current_lang}&defaultLang=#{default_lang}&urlPattern=#{url_pattern}&version=#{Wovnrb::VERSION}"]
|
94
|
+
['data-wovnio', "key=#{user_token}&backend=true¤tLang=#{current_lang}&defaultLang=#{default_lang}&urlPattern=#{url_pattern}&langCodeAliases=#{custom_lang_aliases}&version=#{Wovnrb::VERSION}"]
|
79
95
|
]
|
80
96
|
wovn_data.each do |data|
|
81
97
|
assert_equal(data[1], node.get_attribute(data[0]))
|
data/test/lib/lang_test.rb
CHANGED
@@ -323,7 +323,7 @@ module Wovnrb
|
|
323
323
|
body = "<html lang=\"ja\">
|
324
324
|
<head>
|
325
325
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
326
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
|
326
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
|
327
327
|
</head>
|
328
328
|
<body>
|
329
329
|
<h1>
|
@@ -336,7 +336,7 @@ module Wovnrb
|
|
336
336
|
body = "<html lang=\"ja\">
|
337
337
|
<head>
|
338
338
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
339
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
339
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
340
340
|
</head>
|
341
341
|
<body>
|
342
342
|
<h1>
|
@@ -349,7 +349,7 @@ module Wovnrb
|
|
349
349
|
body = "<html lang=\"ja\">
|
350
350
|
<head>
|
351
351
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
352
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
|
352
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
|
353
353
|
</head>
|
354
354
|
<body wovn-ignore=\"\">
|
355
355
|
<h1>Mr. Belvedere Fan Club</h1>
|
@@ -368,17 +368,17 @@ module Wovnrb
|
|
368
368
|
when "value_double_quote"
|
369
369
|
body = "<html><body><h1>Mr.BelvedereFanClub</h1><div wovn-ignore=\"value\"><p>Hello</p></div></body></html>"
|
370
370
|
when "empty_translated"
|
371
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
371
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
372
372
|
when "empty_single_quote_translated"
|
373
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
373
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
374
374
|
when "empty_double_quote_translated"
|
375
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
375
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
|
376
376
|
when "value_single_quote_translated"
|
377
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
|
377
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
|
378
378
|
when "value_double_quote_translated"
|
379
|
-
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
|
379
|
+
body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
|
380
380
|
when "meta_img_alt_tags_translated"
|
381
|
-
body = "<html lang=\"ja\">\n<head>\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<meta name=\"description\" content=\"こんにちは\">\n<meta name=\"title\" content=\"こんにちは\">\n<meta property=\"og:title\" content=\"こんにちは\">\n<meta property=\"og:description\" content=\"こんにちは\">\n<meta property=\"twitter:title\" content=\"こんにちは\">\n<meta property=\"twitter:description\" content=\"こんにちは\">\n<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">\n</head>\n<body>\n<h1>
|
381
|
+
body = "<html lang=\"ja\">\n<head>\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<meta name=\"description\" content=\"こんにちは\">\n<meta name=\"title\" content=\"こんにちは\">\n<meta property=\"og:title\" content=\"こんにちは\">\n<meta property=\"og:description\" content=\"こんにちは\">\n<meta property=\"twitter:title\" content=\"こんにちは\">\n<meta property=\"twitter:description\" content=\"こんにちは\">\n<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">\n</head>\n<body>\n<h1>
|
382
382
|
<!--wovn-src:Mr. Belvedere Fan Club-->ベルベデアさんファンクラブ</h1>\n<div><p><!--wovn-src:Hello-->こんにちは</p></div>\n<!--wovn-src:Hello--><img src=\"http://example.com/photo.png\" alt=\"こんにちは\">\n</body>\n</html>\n"
|
383
383
|
when "meta_img_alt_tags"
|
384
384
|
body = "<html><head><meta name =\"description\" content=\"Hello\">\n<meta name=\"title\" content=\"Hello\">\n<meta property=\"og:title\" content=\"Hello\">\n<meta property=\"og:description\" content=\"Hello\">\n<meta property=\"twitter:title\" content=\"Hello\">\n<meta property=\"twitter:description\" content=\"Hello\"></head>
|
@@ -386,6 +386,23 @@ module Wovnrb
|
|
386
386
|
<div><p>Hello</p></div>
|
387
387
|
<img src=\"http://example.com/photo.png\" alt=\"Hello\">
|
388
388
|
</body></html>"
|
389
|
+
when "a_href_javascript"
|
390
|
+
body = "<html><body><h1>Mr. Belvedere Fan Club</h1>
|
391
|
+
<div><p><a href=\"javascript:void(0)\">Hello</a></p></div>
|
392
|
+
</body></html>"
|
393
|
+
when "a_href_javascript_translated"
|
394
|
+
body = "<html lang=\"ja\">
|
395
|
+
<head>
|
396
|
+
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
397
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
398
|
+
</head>
|
399
|
+
<body>
|
400
|
+
<h1>
|
401
|
+
<!--wovn-src:Mr. Belvedere Fan Club-->ベルベデアさんファンクラブ</h1>
|
402
|
+
<div><p><a href=\"javascript:void(0)\"><!--wovn-src:Hello-->こんにちは</a></p></div>
|
403
|
+
</body>
|
404
|
+
</html>
|
405
|
+
"
|
389
406
|
else # "" case
|
390
407
|
body = "<html><body><h1>Mr. Belvedere Fan Club</h1>
|
391
408
|
<div><p>Hello</p></div>
|
@@ -443,6 +460,16 @@ module Wovnrb
|
|
443
460
|
assert_equal(generate_body('translated_in_japanese'), swapped_body)
|
444
461
|
end
|
445
462
|
|
463
|
+
def test_switch_lang_href_javascript
|
464
|
+
lang = Lang.new('ja')
|
465
|
+
h = Wovnrb::Headers.new(Wovnrb.get_env('url' => 'http://page.com'), Wovnrb.get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
466
|
+
dom = generate_dom('a_href_javascript')
|
467
|
+
values = generate_values
|
468
|
+
url = h.url
|
469
|
+
swapped_body = lang.switch_dom_lang(dom, Store.instance, values, url, h)
|
470
|
+
assert_equal(generate_body('a_href_javascript_translated'), swapped_body)
|
471
|
+
end
|
472
|
+
|
446
473
|
def test_switch_lang_meta_img_alt_tags
|
447
474
|
lang = Lang.new('ja')
|
448
475
|
h = Wovnrb::Headers.new(Wovnrb.get_env('url' => 'http://page.com'), Wovnrb.get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
@@ -522,5 +549,18 @@ module Wovnrb
|
|
522
549
|
swapped_body = lang.switch_dom_lang(dom, Store.instance, values, url, h)
|
523
550
|
assert_equal(generate_body('value_double_quote_translated'), swapped_body)
|
524
551
|
end
|
552
|
+
|
553
|
+
def test_get_code_from_custom_lang
|
554
|
+
store = Store.instance
|
555
|
+
store.settings['custom_lang_aliases'] = {'ja' => 'staging-ja'}
|
556
|
+
assert_equal('ja', Wovnrb::Lang.get_code('staging-ja'))
|
557
|
+
end
|
558
|
+
|
559
|
+
def test_add_lang_code_with_custom_lang_aliases
|
560
|
+
lang = Lang.new('fr')
|
561
|
+
Store.instance.settings['custom_lang_aliases'] = {'fr' => 'staging-fr'}
|
562
|
+
h = Wovnrb::Headers.new(Wovnrb.get_env('url' => 'http://favy.tips'), Wovnrb.get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
563
|
+
assert_equal("http://staging-fr.favy.tips/topics/50", lang.add_lang_code("/topics/50", 'subdomain', h))
|
564
|
+
end
|
525
565
|
end
|
526
566
|
end
|
data/test/lib/store_test.rb
CHANGED
@@ -83,5 +83,33 @@ module Wovnrb
|
|
83
83
|
|
84
84
|
assert_equal([], s.settings['ignore_globs'])
|
85
85
|
end
|
86
|
+
|
87
|
+
def test_add_custom_lang_aliases_empty
|
88
|
+
s = Wovnrb::Store.instance
|
89
|
+
s.settings({'custom_lang_aliases' => {}})
|
90
|
+
|
91
|
+
assert_equal({}, s.settings['custom_lang_aliases'])
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_add_custom_lang_aliases_single_value
|
95
|
+
s = Wovnrb::Store.instance
|
96
|
+
s.settings({'custom_lang_aliases' => {'ja' => 'staging-ja'}})
|
97
|
+
|
98
|
+
assert_equal({'ja' => 'staging-ja'}, s.settings['custom_lang_aliases'])
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_add_custom_lang_aliases_multiple_values
|
102
|
+
s = Wovnrb::Store.instance
|
103
|
+
s.settings({'custom_lang_aliases' => {'ja' => 'staging-ja', 'en' => 'staging-en'}})
|
104
|
+
|
105
|
+
assert_equal({'ja' => 'staging-ja', 'en' => 'staging-en'}, s.settings['custom_lang_aliases'])
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_add_custom_lang_aliases_using_symbols
|
109
|
+
s = Wovnrb::Store.instance
|
110
|
+
s.settings({'custom_lang_aliases' => {ja: 'staging-ja', en: 'staging-en'}})
|
111
|
+
|
112
|
+
assert_equal({'ja' => 'staging-ja', 'en' => 'staging-en'}, s.settings['custom_lang_aliases'])
|
113
|
+
end
|
86
114
|
end
|
87
115
|
end
|
data/test/lib/wovnrb_test.rb
CHANGED
@@ -63,7 +63,7 @@ class WovnrbTest < Minitest::Test
|
|
63
63
|
expected_body = "<html lang=\"ja\">
|
64
64
|
<head>
|
65
65
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
66
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
66
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
67
67
|
</head>
|
68
68
|
<body>
|
69
69
|
<h1>
|
@@ -88,7 +88,7 @@ class WovnrbTest < Minitest::Test
|
|
88
88
|
expected_body = "<html lang=\"ja\">
|
89
89
|
<head>
|
90
90
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
91
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><noscript><div>test</div></noscript>
|
91
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><noscript><div>test</div></noscript>
|
92
92
|
<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
93
93
|
</head>
|
94
94
|
<body>
|
@@ -116,7 +116,7 @@ class WovnrbTest < Minitest::Test
|
|
116
116
|
expected_body = "<html lang=\"ja\">
|
117
117
|
<head>
|
118
118
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
119
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><noscript>
|
119
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><noscript>
|
120
120
|
<div>test</div>
|
121
121
|
</noscript>
|
122
122
|
<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
@@ -144,7 +144,7 @@ class WovnrbTest < Minitest::Test
|
|
144
144
|
expected_body = "<html lang=\"ja\">
|
145
145
|
<head>
|
146
146
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
147
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><noscript><div>test</div></noscript>
|
147
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><noscript><div>test</div></noscript>
|
148
148
|
<title>plop</title>
|
149
149
|
<noscript><div>test2</div></noscript>
|
150
150
|
<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
@@ -172,7 +172,7 @@ class WovnrbTest < Minitest::Test
|
|
172
172
|
expected_body = "<html lang=\"ja\">
|
173
173
|
<head>
|
174
174
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
175
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><noscript><!-- --><div>test</div></noscript>
|
175
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><noscript><!-- --><div>test</div></noscript>
|
176
176
|
<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
177
177
|
</head>
|
178
178
|
<body>
|
@@ -198,7 +198,7 @@ class WovnrbTest < Minitest::Test
|
|
198
198
|
expected_body = "<html lang=\"ja\">
|
199
199
|
<head>
|
200
200
|
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
201
|
-
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&version=#{Wovnrb::VERSION}\"> </script><!--<noscript><div>test</div></noscript>--><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
201
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><!--<noscript><div>test</div></noscript>--><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
202
202
|
</head>
|
203
203
|
<body>
|
204
204
|
<h1>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wovnrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sandford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-03-
|
12
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|
@@ -330,6 +330,7 @@ files:
|
|
330
330
|
- ".travis.yml"
|
331
331
|
- Gemfile
|
332
332
|
- LICENSE.txt
|
333
|
+
- PULL_REQUEST_TEMPLATE
|
333
334
|
- README.md
|
334
335
|
- Rakefile
|
335
336
|
- circle.yml
|
@@ -396,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
396
397
|
version: '0'
|
397
398
|
requirements: []
|
398
399
|
rubyforge_project:
|
399
|
-
rubygems_version: 2.
|
400
|
+
rubygems_version: 2.6.3
|
400
401
|
signing_key:
|
401
402
|
specification_version: 4
|
402
403
|
summary: Gem for WOVN.io
|
@@ -422,4 +423,3 @@ test_files:
|
|
422
423
|
- test/lib/wovnrb_test.rb
|
423
424
|
- test/services/url_test.rb
|
424
425
|
- test/test_helper.rb
|
425
|
-
has_rdoc:
|