forked from sidekiq/sidekiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_web_helpers.rb
52 lines (39 loc) · 989 Bytes
/
test_web_helpers.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require_relative 'helper'
require 'sidekiq'
require 'sidekiq/web_helpers'
class TestWebHelpers < Sidekiq::Test
class Helpers
include Sidekiq::WebHelpers
def initialize(params={})
@thehash = default.merge(params)
end
def request
self
end
def settings
self
end
def locales
['web/locales']
end
def env
@thehash
end
def default
{
}
end
end
def test_locale_determination
obj = Helpers.new
assert_equal 'en', obj.locale
obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,ru;q=0.2')
assert_equal 'fr', obj.locale
obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => 'zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4,ru;q=0.2')
assert_equal 'zh-cn', obj.locale
obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => 'en-us; *')
assert_equal 'en', obj.locale
obj = Helpers.new('HTTP_ACCEPT_LANGUAGE' => '*')
assert_equal 'en', obj.locale
end
end