From d473a068a2b90aba98135deb225d6eb6d8104d70 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 29 Dec 2008 22:01:34 +0100 Subject: [PATCH] flatten load_path before using it so that a nested array of paths won't throw up --- lib/i18n/backend/simple.rb | 2 +- test/simple_backend_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/i18n/backend/simple.rb b/lib/i18n/backend/simple.rb index d298b3a8..a1f12422 100644 --- a/lib/i18n/backend/simple.rb +++ b/lib/i18n/backend/simple.rb @@ -76,7 +76,7 @@ def reload! protected def init_translations - load_translations(*I18n.load_path) + load_translations(*I18n.load_path.flatten) @initialized = true end diff --git a/test/simple_backend_test.rb b/test/simple_backend_test.rb index e181975f..99cfa6f6 100644 --- a/test/simple_backend_test.rb +++ b/test/simple_backend_test.rb @@ -472,6 +472,18 @@ def test_load_translations_loads_from_different_file_formats end end +class I18nSimpleBackendLoadPathTest < Test::Unit::TestCase + include I18nSimpleBackendTestSetup + + def test_nested_load_paths_do_not_break_locale_loading + @backend = I18n::Backend::Simple.new + I18n.load_path = [[File.dirname(__FILE__) + '/locale/en.yml']] + assert_nil backend_get_translations + assert_nothing_raised { @backend.send :init_translations } + assert_not_nil backend_get_translations + end +end + class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase include I18nSimpleBackendTestSetup