Permalink
Browse files

Add tests for collection_wrapper_class

  • Loading branch information...
1 parent 17e83b5 commit c76224a2ab6dad1715da91dff7de4dd0b11ea1cb @mfila mfila committed Oct 6, 2011
Showing with 34 additions and 0 deletions.
  1. +34 −0 test/action_view_extensions/builder_test.rb
View
34 test/action_view_extensions/builder_test.rb
@@ -120,6 +120,23 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
assert_no_select 'form ul'
end
+ test 'collection radio uses the configured class for collection wrapper tag' do
+ swap SimpleForm, :collection_wrapper_tag => :ul, :collection_wrapper_class => :'inputs-list' do
+ with_collection_radio @user, :active, [true, false], :to_s, :to_s
+
+ assert_select 'form ul.inputs-list input[type=radio][value=true]#user_active_true'
+ assert_select 'form ul.inputs-list input[type=radio][value=false]#user_active_false'
+ end
+ end
+
+ test 'collection radio uses no class for collection wrapper tag by default' do
+ swap SimpleForm, :collection_wrapper_tag => :ul do
+ with_collection_radio @user, :active, [true, false], :to_s, :to_s
+
+ assert_no_select 'form ul[class]'
+ end
+ end
+
test 'collection radio wraps each label/radio in the configured item wrapper tag' do
swap SimpleForm, :item_wrapper_tag => :li do
with_collection_radio @user, :active, [true, false], :to_s, :to_s
@@ -290,6 +307,23 @@ def with_collection_check_boxes(object, attribute, collection, value_method, tex
assert_no_select 'form ul'
end
+ test 'collection check box uses the configured class for collection wrapper tag' do
+ swap SimpleForm, :collection_wrapper_tag => :ul, :collection_wrapper_class => :'inputs-list' do
+ with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s
+
+ assert_select 'form ul.inputs-list input[type=checkbox][value=true]#user_active_true'
+ assert_select 'form ul.inputs-list input[type=checkbox][value=false]#user_active_false'
+ end
+ end
+
+ test 'collection check box uses no class for collection wrapper tag by default' do
+ swap SimpleForm, :collection_wrapper_tag => :ul do
+ with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s
+
+ assert_no_select 'form ul[class]'
+ end
+ end
+
test 'collection check box wraps each label/radio in the configured item wrapper tag' do
swap SimpleForm, :item_wrapper_tag => :li do
with_collection_check_boxes @user, :active, [true, false], :to_s, :to_s

0 comments on commit c76224a

Please sign in to comment.