diff options
-rw-r--r-- | actionview/lib/action_view/helpers/translation_helper.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/translation_helper_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb index d5b0a9263f..baa337c62f 100644 --- a/actionview/lib/action_view/helpers/translation_helper.rb +++ b/actionview/lib/action_view/helpers/translation_helper.rb @@ -60,7 +60,7 @@ module ActionView def translate(key, options = {}) options = options.dup if options.has_key?(:default) - remaining_defaults = Array(options.delete(:default)).compact + remaining_defaults = Array.wrap(options.delete(:default)).compact options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol) end diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index 9afdc3c68f..3475a1dada 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -121,6 +121,11 @@ class TranslationHelperTest < ActiveSupport::TestCase I18n.exception_handler = old_exception_handler end + def test_hash_default + default = { separator: ".", delimiter: "," } + assert_equal default, translate(:'special.number.format', default: default) + end + def test_translation_returning_an_array expected = %w(foo bar) assert_equal expected, translate(:"translations.array") |