mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Previous form and collection tag logic was causing tests to fail. Updated logic and wrote additional tests for explicitly false collection wrapper tags and item wrapper tags.
This commit is contained in:
parent
d10f104ad3
commit
fd5f68615d
2 changed files with 30 additions and 2 deletions
|
@ -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] || SimpleForm.collection_wrapper_tag
|
||||
item_wrapper_tag = (defined? options[:item_wrapper_tag]) ? options[:item_wrapper_tag] : SimpleForm.item_wrapper_tag
|
||||
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
|
||||
|
||||
rendered_collection = collection.map do |item|
|
||||
value = value_for_collection(item, value_method)
|
||||
|
|
|
@ -96,6 +96,13 @@ class BuilderTest < ActionView::TestCase
|
|||
assert_select 'form ul input[type=radio][value=false]#user_active_false'
|
||||
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
|
||||
|
||||
assert_select 'form > input[type=radio][value=true]#user_active_true'
|
||||
assert_select 'form > input[type=radio][value=false]#user_active_false'
|
||||
end
|
||||
|
||||
test 'collection radio does not wrap the collection by default' do
|
||||
with_collection_radio @user, :active, [true, false], :to_s, :to_s
|
||||
|
||||
|
@ -118,6 +125,13 @@ class BuilderTest < ActionView::TestCase
|
|||
assert_select 'form li input[type=radio][value=false]#user_active_false'
|
||||
end
|
||||
|
||||
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'
|
||||
end
|
||||
|
||||
test 'collection radio wrap items in a span tag by default' do
|
||||
with_collection_radio @user, :active, [true, false], :to_s, :to_s
|
||||
|
||||
|
@ -246,6 +260,13 @@ class BuilderTest < ActionView::TestCase
|
|||
assert_select 'form ul input[type=checkbox][value=false]#user_active_false'
|
||||
end
|
||||
|
||||
test 'collection check box does not wrap the collection in the explicitly false collection wrapper tag' do
|
||||
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s, :collection_wrapper_tag => false, :item_wrapper_tag => false
|
||||
|
||||
assert_select 'form > input[type=checkbox][value=true]#user_active_true'
|
||||
assert_select 'form > input[type=checkbox][value=false]#user_active_false'
|
||||
end
|
||||
|
||||
test 'collection check box does not wrap the collection by default' do
|
||||
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s
|
||||
|
||||
|
@ -268,6 +289,13 @@ class BuilderTest < ActionView::TestCase
|
|||
assert_select 'form li input[type=checkbox][value=false]#user_active_false'
|
||||
end
|
||||
|
||||
test 'collection check box does not wrapp each label/radio in the explicitly false item wrapper tag' do
|
||||
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s, :item_wrapper_tag => false
|
||||
|
||||
assert_select 'form > input[type=checkbox][value=true]#user_active_true'
|
||||
assert_select 'form > input[type=checkbox][value=false]#user_active_false'
|
||||
end
|
||||
|
||||
test 'collection check box wrap items in a span tag by default' do
|
||||
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s
|
||||
|
||||
|
|
Loading…
Reference in a new issue