1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #15068 from josepjaume/patch-1

Dup options hash to prevent modifications
This commit is contained in:
Aaron Patterson 2014-05-13 08:04:24 -07:00
commit f0f7c4ff96
2 changed files with 8 additions and 0 deletions

View file

@ -34,6 +34,8 @@ module ActionView
# 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 = options.dup
options[:default] = wrap_translate_defaults(options[:default]) if options[:default]
# If the user has specified rescue_format then pass it all through, otherwise use

View file

@ -151,4 +151,10 @@ class TranslationHelperTest < ActiveSupport::TestCase
translation = translate(:'translations.missing', default: ['A Generic String', 'Second generic string'])
assert_equal 'A Generic String', translation
end
def test_translate_doesnt_change_options
options = {}
translate(:'translations.missing', options)
assert_equal options, {}
end
end