1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Move label I18n test with defaults for associations to labels test file

Also reorganize some hashes and spaces.
This commit is contained in:
Carlos Antonio da Silva 2012-10-26 01:27:53 -02:00
parent f3d7ba7c12
commit 120c364f7d
2 changed files with 27 additions and 27 deletions

View file

@ -72,14 +72,14 @@ class IsolatedLabelTest < ActionView::TestCase
end end
end end
test 'input should use i18n under defaults to lookup translation' do test 'label should use i18n under defaults to lookup translation' do
store_translations(:en, :simple_form => { :labels => { :defaults => { :age => 'Idade' } } }) do store_translations(:en, :simple_form => { :labels => { :defaults => { :age => 'Idade' } } }) do
with_label_for @user, :age, :integer with_label_for @user, :age, :integer
assert_select 'label[for=user_age]', /Idade/ assert_select 'label[for=user_age]', /Idade/
end end
end end
test 'input should not use i18n label if translate is false' do test 'label should not use i18n label if translate is false' do
swap SimpleForm, :translate_labels => false do swap SimpleForm, :translate_labels => false do
store_translations(:en, :simple_form => { :labels => { :defaults => { :age => 'Idade' } } }) do store_translations(:en, :simple_form => { :labels => { :defaults => { :age => 'Idade' } } }) do
with_label_for @user, :age, :integer with_label_for @user, :age, :integer
@ -88,7 +88,7 @@ class IsolatedLabelTest < ActionView::TestCase
end end
end end
test 'label should use i18n with lookup for association name' do test 'label uses i18n with lookup for association name' do
store_translations(:en, :simple_form => { :labels => { store_translations(:en, :simple_form => { :labels => {
:user => { :company => 'My company!' } :user => { :company => 'My company!' }
} }) do } }) do
@ -97,6 +97,16 @@ class IsolatedLabelTest < ActionView::TestCase
end end
end end
test 'label uses i18n under defaults namespace to lookup for association name' do
store_translations(:en, :simple_form => { :labels => {
:defaults => { :company => 'Plataformatec' }
} }) do
with_label_for @user, :company, :string, :setup_association => true
assert_select 'form label', /Plataformatec/
end
end
test 'label should do correct i18n lookup for nested models with nested translation' do test 'label should do correct i18n lookup for nested models with nested translation' do
@user.company = Company.new(1, 'Empresa') @user.company = Company.new(1, 'Empresa')

View file

@ -183,14 +183,4 @@ class AssociationTest < ActionView::TestCase
assert_equal({ :as => :check_boxes, :collection_wrapper_tag => :ul, :item_wrapper_tag => :li}, assert_equal({ :as => :check_boxes, :collection_wrapper_tag => :ul, :item_wrapper_tag => :li},
options) options)
end end
test 'builder association uses i18n under defaults namespace to lookup translation' do
store_translations(:en, :simple_form => {
:labels => {:defaults => {:company => 'Plataformatec' } }
}) do
with_association_for @user, :company, :required => false
assert_select 'form label', 'Plataformatec'
end
end
end end