aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-01-31 17:46:31 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-02 09:40:23 -0200
commit21eba34718660b96b45cbb594d557b7e84bfed4f (patch)
tree8f6d590dfe9077708ac823e2494a9740adf2d267 /actionpack/test/template
parent15206885eb58978465e5f79a4f20cc3c3766de10 (diff)
downloadrails-21eba34718660b96b45cbb594d557b7e84bfed4f.tar.gz
rails-21eba34718660b96b45cbb594d557b7e84bfed4f.tar.bz2
rails-21eba34718660b96b45cbb594d557b7e84bfed4f.zip
Add collection_radio_buttons and collection_check_boxes to FormBuilder
[Carlos Antonio da Silva + Rafael Mendonça França]
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/form_collections_helper_test.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionpack/test/template/form_collections_helper_test.rb
index 647fe47d04..995cfdae87 100644
--- a/actionpack/test/template/form_collections_helper_test.rb
+++ b/actionpack/test/template/form_collections_helper_test.rb
@@ -179,6 +179,20 @@ class FormCollectionsHelperTest < ActionView::TestCase
assert_select 'label[for=user_active_false] > input#user_active_false[type=radio]'
end
+ test 'collection radio buttons with fields for' do
+ collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]
+ concat(fields_for(:post) do |p|
+ p.collection_radio_buttons :category_id, collection, :id, :name
+ end)
+
+ assert_select 'input#post_category_id_1[type=radio][value=1]'
+ assert_select 'input#post_category_id_2[type=radio][value=2]'
+
+ assert_select 'label.collection_radio_buttons[for=post_category_id_1]', 'Category 1'
+ assert_select 'label.collection_radio_buttons[for=post_category_id_2]', 'Category 2'
+ end
+
+
# COLLECTION CHECK BOXES
test 'collection check boxes accepts a collection and generate a serie of checkboxes for value method' do
collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]
@@ -281,19 +295,16 @@ class FormCollectionsHelperTest < ActionView::TestCase
end
test 'collection check boxes with fields for' do
- skip "test collection check boxes with fields for (and radio buttons as well)"
collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')]
- concat(form_for(:user) do |f|
- f.fields_for(:post) do |p|
- p.collection_check_boxes :category_ids, collection, :id, :name
- end
+ concat(fields_for(:post) do |p|
+ p.collection_check_boxes :category_ids, collection, :id, :name
end)
- assert_select 'input#user_post_category_ids_1[type=checkbox][value=1]'
- assert_select 'input#user_post_category_ids_2[type=checkbox][value=2]'
+ assert_select 'input#post_category_ids_1[type=checkbox][value=1]'
+ assert_select 'input#post_category_ids_2[type=checkbox][value=2]'
- assert_select 'label.collection_check_boxes[for=user_post_category_ids_1]', 'Category 1'
- assert_select 'label.collection_check_boxes[for=user_post_category_ids_2]', 'Category 2'
+ assert_select 'label.collection_check_boxes[for=post_category_ids_1]', 'Category 1'
+ assert_select 'label.collection_check_boxes[for=post_category_ids_2]', 'Category 2'
end
test 'collection check boxeses wraps the collection in the given collection wrapper tag' do