Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow back passing :rescue_format => nil and test added

  • Loading branch information...
commit b696dd70db651c6cb4a096dd0d5762416acd9917 1 parent be4551f
Santiago Pastorino spastorino authored
2  actionpack/lib/action_view/helpers/translation_helper.rb
View
@@ -44,7 +44,7 @@ module TranslationHelper
# naming convention helps to identify translations that include HTML tags so that
# you know what kind of output to expect when you call translate in a template.
def translate(key, options = {})
- options[:rescue_format] ||= :html
+ options.merge!(:rescue_format => :html) unless options.key?(:rescue_format)
translation = I18n.translate(scope_key_by_partial(key), options)
if html_safe_translation_key?(key) && translation.respond_to?(:html_safe)
translation.html_safe
5 actionpack/test/template/translation_helper_test.rb
View
@@ -40,6 +40,11 @@ def test_returns_missing_translation_message_wrapped_into_span
assert_equal expected, translate(:"translations.missing")
end
+ def test_returns_missing_translation_message_using_nil_as_rescue_format
+ expected = 'translation missing: en.translations.missing'
+ assert_equal expected, translate(:"translations.missing", :rescue_format => nil)
+ end
+
def test_translation_returning_an_array
expected = %w(foo bar)
assert_equal expected, translate(:"translations.array")
Please sign in to comment.
Something went wrong with that request. Please try again.