Do not modify options hash in human_attribute_name, remove reverse_merge
This commit is contained in:
parent
9fc9e89477
commit
cafe6a38f5
@ -1,5 +1,3 @@
|
||||
require 'active_support/core_ext/hash/reverse_merge'
|
||||
|
||||
module ActiveModel
|
||||
|
||||
# == Active Model Translation
|
||||
@ -43,6 +41,7 @@ def lookup_ancestors
|
||||
#
|
||||
# Specify +options+ with additional translating options.
|
||||
def human_attribute_name(attribute, options = {})
|
||||
options = { :count => 1 }.merge!(options)
|
||||
defaults = []
|
||||
parts = attribute.to_s.split(".", 2)
|
||||
attribute = parts.pop
|
||||
@ -63,7 +62,7 @@ def human_attribute_name(attribute, options = {})
|
||||
defaults << options.delete(:default) if options[:default]
|
||||
defaults << attribute.humanize
|
||||
|
||||
options.reverse_merge! :count => 1, :default => defaults
|
||||
options[:default] = defaults
|
||||
I18n.translate(defaults.shift, options)
|
||||
end
|
||||
end
|
||||
|
@ -82,9 +82,15 @@ def test_translated_model_names_with_ancestors_fallback
|
||||
end
|
||||
|
||||
def test_human_does_not_modify_options
|
||||
options = {:default => 'person model'}
|
||||
options = { :default => 'person model' }
|
||||
Person.model_name.human(options)
|
||||
assert_equal({:default => 'person model'}, options)
|
||||
assert_equal({ :default => 'person model' }, options)
|
||||
end
|
||||
|
||||
def test_human_attribute_name_does_not_modify_options
|
||||
options = { :default => 'Cool gender' }
|
||||
Person.human_attribute_name('gender', options)
|
||||
assert_equal({ :default => 'Cool gender' }, options)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user