Skip to content

Commit

Permalink
add #reload! to Simple backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Oct 28, 2008
1 parent f57b601 commit 36dd2bd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/i18n/backend/simple.rb
Expand Up @@ -68,6 +68,11 @@ def localize(locale, object, format = :default)
def initialized?
@initialized ||= false
end

def reload!
@initialized = false
@translations = nil
end

protected

Expand Down
29 changes: 29 additions & 0 deletions test/simple_backend_test.rb
Expand Up @@ -470,4 +470,33 @@ def test_load_translations_loads_from_different_file_formats
}
assert_equal expected, backend_get_translations
end
end

class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
include I18nSimpleBackendTestSetup

def setup
@backend = I18n::Backend::Simple.new
I18n.load_path = [File.dirname(__FILE__) + '/locale/en-US.yml']
assert_nil backend_get_translations
@backend.send :init_translations
end

def teardown
I18n.load_path = []
end

def test_setup
assert_not_nil backend_get_translations
end

def test_reload_translations_unloads_translations
@backend.reload!
assert_nil backend_get_translations
end

def test_reload_translations_uninitializes_translations
@backend.reload!
assert_equal @backend.initialized?, false
end
end

0 comments on commit 36dd2bd

Please sign in to comment.