From 16fe816827ffa60d9e1a7a34baee33531d08a269 Mon Sep 17 00:00:00 2001 From: Massimiliano Filacchioni Date: Tue, 29 Nov 2011 22:17:48 +0300 Subject: [PATCH] add tests for issue 344 --- test/components/label_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/components/label_test.rb b/test/components/label_test.rb index 6373a2f6..36bde220 100644 --- a/test/components/label_test.rb +++ b/test/components/label_test.rb @@ -247,6 +247,33 @@ class IsolatedLabelTest < ActionView::TestCase assert_select 'label[for=project_name]', /Name/ end + test 'label should include for attribute for select collection' do + with_label_for @user, :sex, :select, :collection => [:male, :female] + assert_select 'label[for=user_sex]' + end + + test 'label should not include for attribute for radio collection' do + with_label_for @user, :sex, :radio, :collection => [:male, :female] + assert_select 'label' + assert_no_select 'label[for=user_sex]' + end + + test 'label should include for attribute for radio collection when overwritten' do + with_label_for @user, :sex, :radio, :collection => [:male, :female], :label_html => { :for => 'sex' } + assert_select 'label[for=sex]' + end + + test 'label should not include for attribute for check box collection' do + with_label_for @user, :hobbies, :check_boxes, :collection => [:sports, :movies, :shopping] + assert_select 'label' + assert_no_select 'label[for=user_hobbies]' + end + + test 'label should include for attribute for check box collection when overwritten' do + with_label_for @user, :hobbies, :check_boxes, :collection => [:sports, :movies, :shopping], :label_html => { :for => 'hobbies' } + assert_select 'label[for=hobbies]' + end + test 'label should use i18n properly when object is not present' do store_translations(:en, :simple_form => { :labels => { :project => { :name => 'Nome' }