From 63458994896c6e1b57f5c8716c637d74f1bb1c9e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 26 Sep 2010 00:01:10 +0800 Subject: Remove last tests with deprecated form_for and cleanup form_for helper This cleans up the last bits of deprecation stuff from form_for helper. However there is still a bug when using :as => foo[], with index. The classes and ids are being generated using [], such as foo[]_edit. This bug already existed but it was not detected before. --- actionpack/test/template/form_helper_test.rb | 112 ++++++++++++--------------- 1 file changed, 49 insertions(+), 63 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 3c2db73b6e..b3fae4d564 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -816,16 +816,14 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_index - assert_deprecated do - form_for("post[]", @post) do |f| - concat f.label(:title) - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + form_for(@post, :as => "post[]") do |f| + concat f.label(:title) + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) end - expected = whole_form do + expected = whole_form('/posts/123', 'post[]_edit', 'post[]_edit', 'put') do "" + "" + "" + @@ -837,15 +835,13 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_nil_index_option_override - assert_deprecated do - form_for("post[]", @post, :index => nil) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + form_for(@post, :as => "post[]", :index => nil) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) end - expected = whole_form do + expected = whole_form('/posts/123', 'post[]_edit', 'post[]_edit', 'put') do "" + "" + "" + @@ -936,16 +932,14 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for_with_nested_collections - assert_deprecated do - form_for('post[]', @post) do |f| - concat f.text_field(:title) - concat f.fields_for('comment[]', @comment) { |c| - concat c.text_field(:name) - } - end + form_for(@post, :as => 'post[]') do |f| + concat f.text_field(:title) + concat f.fields_for('comment[]', @comment) { |c| + concat c.text_field(:name) + } end - expected = whole_form do + expected = whole_form('/posts/123', 'post[]_edit', 'post[]_edit', 'put') do "" + "" end @@ -954,16 +948,14 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for_with_index_and_parent_fields - assert_deprecated do - form_for('post', @post, :index => 1) do |c| - concat c.text_field(:title) - concat c.fields_for('comment', @comment, :index => 1) { |r| - concat r.text_field(:name) - } - end + form_for(@post, :index => 1) do |c| + concat c.text_field(:title) + concat c.fields_for('comment', @comment, :index => 1) { |r| + concat r.text_field(:name) + } end - expected = whole_form do + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do "" + "" end @@ -1000,15 +992,13 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for_with_auto_index - assert_deprecated do - form_for("post[]", @post) do |f| - concat f.fields_for(:comment, @post) { |c| - concat c.text_field(:title) - } - end + form_for(@post, :as => "post[]") do |f| + concat f.fields_for(:comment, @post) { |c| + concat c.text_field(:title) + } end - expected = whole_form do + expected = whole_form('/posts/123', 'post[]_edit', 'post[]_edit', 'put') do "" end @@ -1030,15 +1020,13 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for_with_auto_index_on_both - assert_deprecated do - form_for("post[]", @post) do |f| - concat f.fields_for("comment[]", @post) { |c| - concat c.text_field(:title) - } - end + form_for(@post, :as => "post[]") do |f| + concat f.fields_for("comment[]", @post) { |c| + concat c.text_field(:title) + } end - expected = whole_form do + expected = whole_form('/posts/123', 'post[]_edit', 'post[]_edit', 'put') do "" end @@ -1046,27 +1034,25 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for_with_index_and_auto_index - assert_deprecated do - output_buffer = form_for("post[]", @post) do |f| - concat f.fields_for(:comment, @post, :index => 5) { |c| - concat c.text_field(:title) - } - end - - output_buffer << form_for(:post, @post, :index => 1) do |f| - concat f.fields_for("comment[]", @post) { |c| - concat c.text_field(:title) - } - end + output_buffer = form_for(@post, :as => "post[]") do |f| + concat f.fields_for(:comment, @post, :index => 5) { |c| + concat c.text_field(:title) + } + end - expected = whole_form do - "" - end + whole_form do - "" - end + output_buffer << form_for(@post, :as => :post, :index => 1) do |f| + concat f.fields_for("comment[]", @post) { |c| + concat c.text_field(:title) + } + end - assert_dom_equal expected, output_buffer + expected = whole_form('/posts/123', 'post[]_edit', 'post[]_edit', 'put') do + "" + end + whole_form('/posts/123', 'post_edit', 'post_edit', 'put') do + "" end + + assert_dom_equal expected, output_buffer end def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association -- cgit v1.2.3