1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Clean up global state changes in custom web test, fixes #2752

This commit is contained in:
Mike Perham 2016-01-06 10:29:41 -08:00
parent bf9ba449d8
commit f8baa8af37
2 changed files with 16 additions and 6 deletions

View file

@ -17,6 +17,11 @@ module Sidekiq
end end
end end
def clear_caches
@@strings = nil
@@locale_files = nil
end
def locale_files def locale_files
@@locale_files ||= settings.locales.flat_map do |path| @@locale_files ||= settings.locales.flat_map do |path|
Dir["#{path}/*.yml"] Dir["#{path}/*.yml"]

View file

@ -369,19 +369,24 @@ class TestWeb < Sidekiq::Test
assert_equal 200, last_response.status assert_equal 200, last_response.status
end end
describe 'custom locales' do
before do
Sidekiq::Web.settings.locales << File.join(File.dirname(__FILE__), "fixtures") Sidekiq::Web.settings.locales << File.join(File.dirname(__FILE__), "fixtures")
it 'can show user defined tab with custom locales' do
begin
Sidekiq::Web.tabs['Custom Tab'] = '/custom' Sidekiq::Web.tabs['Custom Tab'] = '/custom'
Sidekiq::Web.get('/custom') do Sidekiq::Web.get('/custom') do
clear_caches # ugly hack since I can't figure out how to access WebHelpers outside of this context
t('translated_text') t('translated_text')
end end
end
after do
Sidekiq::Web.tabs.delete 'Custom Tab'
Sidekiq::Web.settings.locales.pop
end
it 'can show user defined tab with custom locales' do
get '/custom' get '/custom'
assert_match(/Changed text/, last_response.body) assert_match(/Changed text/, last_response.body)
ensure
Sidekiq::Web.tabs.delete 'Custom Tab'
end end
end end