Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add #reload! to Simple backend

  • Loading branch information...
commit 36dd2bd9973b9e1559728749a9daafa44693e964 1 parent f57b601
@svenfuchs authored
Showing with 34 additions and 0 deletions.
  1. +5 −0 lib/i18n/backend/simple.rb
  2. +29 −0 test/simple_backend_test.rb
View
5 lib/i18n/backend/simple.rb
@@ -68,6 +68,11 @@ def localize(locale, object, format = :default)
def initialized?
@initialized ||= false
end
+
+ def reload!
+ @initialized = false
+ @translations = nil
+ end
protected
View
29 test/simple_backend_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.