diff --git a/test/components/label_test.rb b/test/components/label_test.rb index ca7c4ee4..22f097b2 100644 --- a/test/components/label_test.rb +++ b/test/components/label_test.rb @@ -132,6 +132,25 @@ class LabelTest < ActionView::TestCase assert_select 'label[for=user_company_attributes_name]', /Nome da empresa/ end end + + test 'label should do correct i18n lookup for nested has_many models with no nested translation' do + @user.tags = [Tag.new(1, 'Empresa')] + + store_translations(:en, :simple_form => { :labels => { + :user => { :name => 'Usuario' }, + :tag => { :name => 'Nome da empresa' } + } } ) do + with_concat_form_for @user do |f| + concat f.input :name + concat(f.simple_fields_for(:tags) do |tags_form| + concat(tags_form.input :name) + end) + end + + assert_select 'label[for=user_name]', /Usuario/ + assert_select 'label[for=user_tags_attributes_0_name]', /Nome da empresa/ + end + end test 'label should have css class from type' do with_label_for @user, :name, :string diff --git a/test/support/models.rb b/test/support/models.rb index 45ad2e54..254e5b46 100644 --- a/test/support/models.rb +++ b/test/support/models.rb @@ -61,6 +61,9 @@ class User def company_attributes=(*) end + def tags_attributes=(*) + end + def column_for_attribute(attribute) column_type, limit = case attribute.to_sym when :name, :status, :password then [:string, 100]