mirror of
https://github.com/github/rails.git
synced 2026-01-09 22:58:09 -05:00
default could be a symbol here so attribute.to_s.humanize should be the final option
This commit is contained in:
@@ -48,7 +48,8 @@ module ActiveModel
|
||||
end
|
||||
|
||||
defaults << :"attributes.#{attribute}"
|
||||
defaults << (options[:default] ? options.delete(:default) : attribute.to_s.humanize)
|
||||
defaults << options.delete(:default) if options[:default]
|
||||
defaults << attribute.to_s.humanize
|
||||
|
||||
options.reverse_merge! :count => 1, :default => defaults
|
||||
I18n.translate(defaults.shift, options)
|
||||
|
||||
@@ -25,6 +25,10 @@ class ActiveModelI18nTests < ActiveModel::TestCase
|
||||
assert_equal 'Name', Person.human_attribute_name('name')
|
||||
end
|
||||
|
||||
def test_translated_model_attributes_using_default_option_as_symbol_and_falling_back_to_default
|
||||
assert_equal 'Name', Person.human_attribute_name('name', :default => :default_name)
|
||||
end
|
||||
|
||||
def test_translated_model_attributes_with_symbols
|
||||
I18n.backend.store_translations 'en', :activemodel => {:attributes => {:person => {:name => 'person name attribute'} } }
|
||||
assert_equal 'person name attribute', Person.human_attribute_name(:name)
|
||||
|
||||
Reference in New Issue
Block a user