From 029936efbe7318e9146c22c6609e1571c7abb0c1 Mon Sep 17 00:00:00 2001 From: Tsutomu Kuroda Date: Wed, 6 Jun 2012 12:45:37 +0900 Subject: Fix human attribute_name to handle deeply nested attributes This is a back-port of b0e2fc84 to Rails 3.2. See #5843 and #3859 also. --- activemodel/test/cases/translation_test.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activemodel/test') diff --git a/activemodel/test/cases/translation_test.rb b/activemodel/test/cases/translation_test.rb index 54e86d48db..6bf92359c5 100644 --- a/activemodel/test/cases/translation_test.rb +++ b/activemodel/test/cases/translation_test.rb @@ -56,6 +56,11 @@ class ActiveModelI18nTests < ActiveModel::TestCase assert_equal 'person gender attribute', Person::Gender.human_attribute_name('attribute') end + def test_translated_deeply_nested_model_attributes + I18n.backend.store_translations 'en', :activemodel => {:attributes => {:"person/contacts/addresses" => {:street => 'Deeply Nested Address Street'}}} + assert_equal 'Deeply Nested Address Street', Person.human_attribute_name('contacts.addresses.street') + end + def test_translated_nested_model_attributes I18n.backend.store_translations 'en', :activemodel => {:attributes => {:"person/addresses" => {:street => 'Person Address Street'}}} assert_equal 'Person Address Street', Person.human_attribute_name('addresses.street') -- cgit v1.2.3