From e2519a421cefa85e70e4d2cf0d767672dadb7e8b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 10 Dec 2009 22:07:13 -0200 Subject: [PATCH] Change label class from collection_radio to ensure we do not have conflicts with component label --- .../action_view_extensions/builder.rb | 2 +- test/action_view_extensions/builder_test.rb | 4 ++-- test/components/input_test.rb | 20 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/simple_form/action_view_extensions/builder.rb b/lib/simple_form/action_view_extensions/builder.rb index 4d3b0efc..6fc34651 100644 --- a/lib/simple_form/action_view_extensions/builder.rb +++ b/lib/simple_form/action_view_extensions/builder.rb @@ -25,7 +25,7 @@ module SimpleForm text = item.send text_method result << radio_button(attribute, value, html_options) << - label("#{attribute}_#{value}", text, :class => "radio") + label("#{attribute}_#{value}", text, :class => "collection_radio") end end diff --git a/test/action_view_extensions/builder_test.rb b/test/action_view_extensions/builder_test.rb index 4182d316..dc1ae813 100644 --- a/test/action_view_extensions/builder_test.rb +++ b/test/action_view_extensions/builder_test.rb @@ -7,10 +7,10 @@ class BuilderTest < ActionView::TestCase end assert_select 'form input[type=radio][value=true]#user_active_true' - assert_select 'form label[for=user_active_true]', 'true' + assert_select 'form label.collection_radio[for=user_active_true]', 'true' assert_select 'form input[type=radio][value=false]#user_active_false' - assert_select 'form label[for=user_active_false]', 'false' + assert_select 'form label.collection_radio[for=user_active_false]', 'false' end test 'collection radio accepts a collection and generate inputs from label method' do diff --git a/test/components/input_test.rb b/test/components/input_test.rb index fbbb9fbf..357ae468 100644 --- a/test/components/input_test.rb +++ b/test/components/input_test.rb @@ -139,15 +139,15 @@ class InputTest < ActionView::TestCase test 'input as radio should generate internal labels by default' do with_input_for @user, :active, :radio - assert_select 'label.radio[for=user_active_true]', 'Yes' - assert_select 'label.radio[for=user_active_false]', 'No' + assert_select 'label[for=user_active_true]', 'Yes' + assert_select 'label[for=user_active_false]', 'No' end test 'input as radio should use i18n to translate internal labels' do store_translations(:en, :simple_form => { :true => 'Sim', :false => 'Não' }) do with_input_for @user, :active, :radio - assert_select 'label.radio[for=user_active_true]', 'Sim' - assert_select 'label.radio[for=user_active_false]', 'Não' + assert_select 'label[for=user_active_true]', 'Sim' + assert_select 'label[for=user_active_false]', 'Não' end end @@ -206,8 +206,8 @@ class InputTest < ActionView::TestCase with_input_for @user, :name, :radio, :collection => ['Jose', 'Carlos'] assert_select 'input[type=radio][value=Jose]' assert_select 'input[type=radio][value=Carlos]' - assert_select 'label.radio', 'Jose' - assert_select 'label.radio', 'Carlos' + assert_select 'label.collection_radio', 'Jose' + assert_select 'label.collection_radio', 'Carlos' end test 'input should mark the current radio value by default' do @@ -220,8 +220,8 @@ class InputTest < ActionView::TestCase with_input_for @user, :name, :radio, :collection => [['Jose', 'jose'], ['Carlos', 'carlos']] assert_select 'input[type=radio][value=jose]' assert_select 'input[type=radio][value=carlos]' - assert_select 'label.radio', 'Jose' - assert_select 'label.radio', 'Carlos' + assert_select 'label.collection_radio', 'Jose' + assert_select 'label.collection_radio', 'Carlos' end test 'input should allow overriding label and value method for collections' do @@ -231,8 +231,8 @@ class InputTest < ActionView::TestCase :value_method => :downcase assert_select 'input[type=radio][value=jose]' assert_select 'input[type=radio][value=carlos]' - assert_select 'label.radio', 'JOSE' - assert_select 'label.radio', 'CARLOS' + assert_select 'label.collection_radio', 'JOSE' + assert_select 'label.collection_radio', 'CARLOS' end test 'input should be required by default' do