From f506c8063b3084f54aa8bd157d94f10b7aed2bf0 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Wed, 1 Feb 2012 19:16:58 -0200 Subject: Add changelog, docs and guides entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Carlos Antonio da Silva + Rafael Mendonça França] --- .../test/template/form_collections_helper_test.rb | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionpack/test/template/form_collections_helper_test.rb index 926be24044..3839aa2a00 100644 --- a/actionpack/test/template/form_collections_helper_test.rb +++ b/actionpack/test/template/form_collections_helper_test.rb @@ -83,7 +83,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'label input' end - test 'collection radio accepts a block to render the radio and label as required' do + test 'collection radio accepts a block to render the label as radio button wrapper' do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| b.label { b.radio_button } end @@ -92,6 +92,15 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select 'label[for=user_active_false] > input#user_active_false[type=radio]' end + test 'collection radio accepts a block to change the order of label and radio button' do + with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| + b.label + b.radio_button + end + + assert_select 'label[for=user_active_true] + input#user_active_true[type=radio]' + 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')] @output_buffer = fields_for(:post) do |p| @@ -228,7 +237,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'label input' end - test 'collection check boxes accepts a block to render the radio and label as required' do + test 'collection check boxes accepts a block to render the label as check box wrapper' do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| b.label { b.check_box } end @@ -236,4 +245,13 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select 'label[for=user_active_true] > input#user_active_true[type=checkbox]' assert_select 'label[for=user_active_false] > input#user_active_false[type=checkbox]' end + + test 'collection check boxes accepts a block to change the order of label and check box' do + with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| + b.label + b.check_box + end + + assert_select 'label[for=user_active_true] + input#user_active_true[type=checkbox]' + assert_select 'label[for=user_active_false] + input#user_active_false[type=checkbox]' + end end -- cgit v1.2.3