1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/test/test_web_helpers.rb
Mike Perham 53e6b9e2df Test suite overhaul
Remove Redis mocking.  Minimize Redis flushing where possible.
2015-09-23 10:56:37 -07:00

50 lines
941 B
Ruby

require_relative 'helper'
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