From 5979ad31fd2249303fd9e436e63568d6f0e22b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 26 Feb 2012 18:47:08 -0300 Subject: Move all the helpers to protected section --- actionpack/test/template/form_helper_test.rb | 62 ++++++++++++++-------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 3546bd3bee..99b46e0990 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1999,37 +1999,6 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end - def hidden_fields(method = nil) - txt = %{
} - txt << %{} - if method && !method.to_s.in?(['get', 'post']) - txt << %{} - end - txt << %{
} - end - - def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) - txt = %{
} - end - - def whole_form(action = "/", id = nil, html_class = nil, options = nil) - contents = block_given? ? yield : "" - - if options.is_a?(Hash) - method, remote, multipart = options.values_at(:method, :remote, :multipart) - else - method = options - end - - form_text(action, id, html_class, remote, multipart, method) + hidden_fields(method) + contents + "
" - end - def test_default_form_builder old_default_form_builder, ActionView::Base.default_form_builder = ActionView::Base.default_form_builder, LabelledFormBuilder @@ -2213,6 +2182,37 @@ class FormHelperTest < ActionView::TestCase protected + def hidden_fields(method = nil) + txt = %{
} + txt << %{} + if method && !method.to_s.in?(['get', 'post']) + txt << %{} + end + txt << %{
} + end + + def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) + txt = %{
} + end + + def whole_form(action = "/", id = nil, html_class = nil, options = nil) + contents = block_given? ? yield : "" + + if options.is_a?(Hash) + method, remote, multipart = options.values_at(:method, :remote, :multipart) + else + method = options + end + + form_text(action, id, html_class, remote, multipart, method) + hidden_fields(method) + contents + "
" + end + def protect_against_forgery? false end -- cgit v1.2.3 From 2ff884c74888e9133120782b9be14e3ef97f3958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 26 Feb 2012 19:02:46 -0300 Subject: Fix collection_check_boxes and collection_radio_buttons when using local variables in the form builder --- actionpack/test/template/form_helper_test.rb | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 99b46e0990..63970d0a89 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -771,6 +771,44 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_with_collection_radio_buttons + post = Post.new + def post.active; false; end + form_for(post) do |f| + concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) + end + + expected = whole_form("/posts", "new_post" , "new_post") do + "" + + "" + + "" + + "" + end + + assert_dom_equal expected, output_buffer + end + + def test_form_for_with_collection_check_boxes + post = Post.new + def post.tag_ids; [1, 3]; end + collection = (1..3).map{|i| [i, "Tag #{i}"] } + form_for(post) do |f| + concat f.collection_check_boxes(:tag_ids, collection, :first, :last) + end + + expected = whole_form("/posts", "new_post" , "new_post") do + "" + + "" + + "" + + "" + + "" + + "" + + "" + end + + assert_dom_equal expected, output_buffer + end + def test_form_for_with_file_field_generate_multipart Post.send :attr_accessor, :file -- cgit v1.2.3