diff --git a/lib/simple_form/action_view_extensions/builder.rb b/lib/simple_form/action_view_extensions/builder.rb index ca12978b..612e6d1b 100644 --- a/lib/simple_form/action_view_extensions/builder.rb +++ b/lib/simple_form/action_view_extensions/builder.rb @@ -134,8 +134,8 @@ module SimpleForm end def render_collection(attribute, collection, value_method, text_method, options={}, html_options={}) #:nodoc: - collection_wrapper_tag = (options[:collection_wrapper_tag] || options[:collection_wrapper_tag] === false) ? options[:collection_wrapper_tag] : SimpleForm.collection_wrapper_tag - item_wrapper_tag = (options[:item_wrapper_tag] || options[:item_wrapper_tag] === false) ? options[:item_wrapper_tag] : SimpleForm.item_wrapper_tag + collection_wrapper_tag = options.has_key?(:collection_wrapper_tag) ? options[:collection_wrapper_tag] : SimpleForm.collection_wrapper_tag + item_wrapper_tag = options.has_key?(:item_wrapper_tag) ? options[:item_wrapper_tag] : SimpleForm.item_wrapper_tag rendered_collection = collection.map do |item| value = value_for_collection(item, value_method) diff --git a/test/action_view_extensions/builder_test.rb b/test/action_view_extensions/builder_test.rb index 1c8a62d3..3a2252c3 100644 --- a/test/action_view_extensions/builder_test.rb +++ b/test/action_view_extensions/builder_test.rb @@ -97,10 +97,21 @@ class BuilderTest < ActionView::TestCase end test 'collection radio does not wrap the collection in the explicitly false collection wrapper tag' do - with_collection_radio @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => false, :item_wrapper_tag => false + swap SimpleForm, :collection_wrapper_tag => :ul do + with_collection_radio @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => false - assert_select 'form > input[type=radio][value=true]#user_active_true' - assert_select 'form > input[type=radio][value=false]#user_active_false' + assert_no_select 'form ul' + assert_no_select 'form ul' + end + end + + test 'collection radio does not wrap the collection in the explicitly nil collection wrapper tag' do + swap SimpleForm, :collection_wrapper_tag => :ul do + with_collection_radio @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => nil + + assert_no_select 'form ul' + assert_no_select 'form ul' + end end test 'collection radio does not wrap the collection by default' do @@ -128,8 +139,15 @@ class BuilderTest < ActionView::TestCase test 'collection radio does not wrap each label/radio in the explicitly false item wrapper tag' do with_collection_radio @user, :active, [true, false], :to_s, :to_s, :item_wrapper_tag => false - assert_select 'form > input[type=radio][value=true]#user_active_true' - assert_select 'form > input[type=radio][value=false]#user_active_false' + assert_no_select 'form span input[type=radio][value=true]#user_active_true' + assert_no_select 'form span input[type=radio][value=false]#user_active_false' + end + + test 'collection radio does not wrap each label/radio in the explicitly nil item wrapper tag' do + with_collection_radio @user, :active, [true, false], :to_s, :to_s, :item_wrapper_tag => nil + + assert_no_select 'form span input[type=radio][value=true]#user_active_true' + assert_no_select 'form span input[type=radio][value=false]#user_active_false' end test 'collection radio wrap items in a span tag by default' do