From 8a16485a9667f9278b7d03f4556edbdeaf27ec5a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 25 Sep 2010 22:49:46 +0800 Subject: Review most of the form_for deprecated tests, missing tests with index like [] --- actionpack/test/lib/controller/fake_models.rb | 1 + actionpack/test/template/form_helper_test.rb | 726 ++++++++++++-------------- 2 files changed, 322 insertions(+), 405 deletions(-) diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb index c4127ee699..8cb3b4940a 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -91,6 +91,7 @@ class Comment attr_accessor :relevances def relevances_attributes=(attributes); end + attr_accessor :body end class Tag diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index d40dd409b8..3c2db73b6e 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -647,26 +647,22 @@ class FormHelperTest < ActionView::TestCase end def test_form_for - assert_deprecated do - form_for(:post, @post, :html => { :id => 'create-post' }) do |f| - concat f.label(:title) { "The Title" } - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - concat f.submit('Create post') - end + form_for(@post, :html => { :id => 'create-post' }) do |f| + concat f.label(:title) { "The Title" } + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + concat f.submit('Create post') end - expected = - "
" + - snowman + + expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put") do "" + "" + "" + "" + "" + - "" + - "
" + "" + end assert_dom_equal expected, output_buffer end @@ -674,17 +670,13 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_file_field_generate_multipart Post.send :attr_accessor, :file - assert_deprecated do - form_for(:post, @post, :html => { :id => 'create-post' }) do |f| - concat f.file_field(:file) - end + form_for(@post, :html => { :id => 'create-post' }) do |f| + concat f.file_field(:file) end - expected = - "
" + - snowman + - "" + - "
" + expected = whole_form("/posts/123", "create-post" , "edit_post", :method => "put", :multipart => true) do + "" + end assert_dom_equal expected, output_buffer end @@ -692,19 +684,15 @@ class FormHelperTest < ActionView::TestCase def test_fields_for_with_file_field_generate_multipart Comment.send :attr_accessor, :file - assert_deprecated do - form_for(:post, @post) do |f| - concat f.fields_for(:comment, @post) { |c| - concat c.file_field(:file) - } - end + form_for(@post) do |f| + concat f.fields_for(:comment, @post) { |c| + concat c.file_field(:file) + } end - expected = - "
" + - snowman + - "" + - "
" + expected = whole_form("/posts/123", "edit_post_123" , "edit_post", :method => "put", :multipart => true) do + "" + end assert_dom_equal expected, output_buffer end @@ -759,15 +747,13 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_method - assert_deprecated do - form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + form_for(@post, :url => '/', :html => { :id => 'create-post', :method => :put }) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) end - expected = whole_form("/", "create-post", nil, "put") do + expected = whole_form("/", "create-post", "edit_post", "put") do "" + "" + "" + @@ -778,15 +764,13 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_remote - assert_deprecated do - form_for(:post, @post, :remote => true, :html => { :id => 'create-post', :method => :put }) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + form_for(@post, :url => '/', :remote => true, :html => { :id => 'create-post', :method => :put }) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) end - expected = whole_form("/", "create-post", nil, :method => "put", :remote => true) do + expected = whole_form("/", "create-post", "edit_post", :method => "put", :remote => true) do "" + "" + "" + @@ -797,15 +781,14 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_remote_without_html - assert_deprecated do - form_for(:post, @post, :remote => true) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + @post.persisted = false + form_for(@post, :remote => true) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) end - expected = whole_form("/", nil, nil, :remote => true) do + expected = whole_form("/posts", 'new_post', 'new_post', :remote => true) do "" + "" + "" + @@ -822,7 +805,7 @@ class FormHelperTest < ActionView::TestCase concat f.check_box(:secret) end - expected = whole_form("/", "create-post") do + expected = whole_form("/", "create-post") do "" + "" + "" + @@ -876,15 +859,13 @@ class FormHelperTest < ActionView::TestCase old_locale, I18n.locale = I18n.locale, :submit @post.persisted = false - assert_deprecated do - form_for(:post, @post) do |f| - concat f.submit - end + form_for(@post) do |f| + concat f.submit end - expected = whole_form do - "" - end + expected = whole_form('/posts', 'new_post', 'new_post') do + "" + end assert_dom_equal expected, output_buffer ensure @@ -894,15 +875,13 @@ class FormHelperTest < ActionView::TestCase def test_submit_with_object_as_existing_record_and_locale_strings old_locale, I18n.locale = I18n.locale, :submit - assert_deprecated do - form_for(:post, @post) do |f| - concat f.submit - end + form_for(@post) do |f| + concat f.submit end - expected = whole_form do - "" - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + "" + end assert_dom_equal expected, output_buffer ensure @@ -916,9 +895,9 @@ class FormHelperTest < ActionView::TestCase concat f.submit :class => "extra" end - expected = whole_form do - "" - end + expected = whole_form do + "" + end assert_dom_equal expected, output_buffer ensure @@ -928,15 +907,13 @@ class FormHelperTest < ActionView::TestCase def test_submit_with_object_and_nested_lookup old_locale, I18n.locale = I18n.locale, :submit - assert_deprecated do - form_for(:another_post, @post) do |f| - concat f.submit - end + form_for(@post, :as => :another_post) do |f| + concat f.submit end - expected = whole_form do - "" - end + expected = whole_form('/posts/123', 'another_post_edit', 'another_post_edit', :method => 'put') do + "" + end assert_dom_equal expected, output_buffer ensure @@ -944,17 +921,16 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for - assert_deprecated do - form_for(:post, @post) do |f| - concat f.fields_for(:comment, @post) { |c| - concat c.text_field(:title) - } - end + @comment.body = 'Hello World' + form_for(@post) do |f| + concat f.fields_for(@comment) { |c| + concat c.text_field(:body) + } end - expected = whole_form do - "" - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + "" + end assert_dom_equal expected, output_buffer end @@ -969,10 +945,10 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form do - "" + - "" - end + expected = whole_form do + "" + + "" + end assert_dom_equal expected, output_buffer end @@ -987,42 +963,38 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form do - "" + - "" - end + expected = whole_form do + "" + + "" + end assert_dom_equal expected, output_buffer end def test_form_for_with_index_and_nested_fields_for - assert_deprecated do - 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, :index => 1) do |f| + concat f.fields_for(:comment, @post) { |c| + concat c.text_field(:title) + } end - expected = whole_form do - "" - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do + "" + end assert_dom_equal expected, output_buffer end def test_nested_fields_for_with_index_on_both - assert_deprecated do - form_for(:post, @post, :index => 1) do |f| - concat f.fields_for(:comment, @post, :index => 5) { |c| - concat c.text_field(:title) - } - end + form_for(@post, :index => 1) do |f| + concat f.fields_for(:comment, @post, :index => 5) { |c| + concat c.text_field(:title) + } end - expected = whole_form do - "" - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do + "" + end assert_dom_equal expected, output_buffer end @@ -1036,25 +1008,23 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form do - "" - end + expected = whole_form do + "" + end assert_dom_equal expected, output_buffer end def test_nested_fields_for_with_index_radio_button - assert_deprecated do - form_for(:post, @post) do |f| - concat f.fields_for(:comment, @post, :index => 5) { |c| - concat c.radio_button(:title, "hello") - } - end + form_for(@post) do |f| + concat f.fields_for(:comment, @post, :index => 5) { |c| + concat c.radio_button(:title, "hello") + } end - expected = whole_form do - "" - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', 'put') do + "" + end assert_dom_equal expected, output_buffer end @@ -1068,9 +1038,9 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form do - "" - end + expected = whole_form do + "" + end assert_dom_equal expected, output_buffer end @@ -1102,30 +1072,26 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association @post.author = Author.new - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.fields_for(:author) { |af| - concat af.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + concat f.fields_for(:author) { |af| + concat af.text_field(:name) + } end - expected = whole_form do - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + end assert_dom_equal expected, output_buffer end def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association - assert_deprecated do - form_for(:post, @post) do |f| - f.fields_for(:author, Author.new(123)) do |af| - assert_not_nil af.object - assert_equal 123, af.object.id - end + form_for(@post) do |f| + f.fields_for(:author, Author.new(123)) do |af| + assert_not_nil af.object + assert_equal 123, af.object.id end end end @@ -1133,20 +1099,18 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association @post.author = Author.new(321) - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.fields_for(:author) { |af| - concat af.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + concat f.fields_for(:author) { |af| + concat af.text_field(:name) + } end - expected = whole_form do - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1154,21 +1118,19 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_existing_records_on_a_nested_attributes_one_to_one_association_with_explicit_hidden_field_placement @post.author = Author.new(321) - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.fields_for(:author) { |af| - concat af.hidden_field(:id) - concat af.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + concat f.fields_for(:author) { |af| + concat af.hidden_field(:id) + concat af.text_field(:name) + } end - expected = whole_form do - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1176,24 +1138,22 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - concat f.fields_for(:comments, comment) { |cf| - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + concat f.fields_for(:comments, comment) { |cf| + concat cf.text_field(:name) + } end end - expected = whole_form do - '' + - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1201,25 +1161,23 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_explicit_hidden_field_placement @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - concat f.fields_for(:comments, comment) { |cf| - concat cf.hidden_field(:id) - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + concat f.fields_for(:comments, comment) { |cf| + concat cf.hidden_field(:id) + concat cf.text_field(:name) + } end end - expected = whole_form do - '' + - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1227,22 +1185,20 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association @post.comments = [Comment.new, Comment.new] - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - concat f.fields_for(:comments, comment) { |cf| - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + concat f.fields_for(:comments, comment) { |cf| + concat cf.text_field(:name) + } end end - expected = whole_form do - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1250,40 +1206,36 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association @post.comments = [Comment.new(321), Comment.new] - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - @post.comments.each do |comment| - concat f.fields_for(:comments, comment) { |cf| - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + concat f.fields_for(:comments, comment) { |cf| + concat cf.text_field(:name) + } end end - expected = whole_form do - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end def test_nested_fields_for_with_an_empty_supplied_attributes_collection - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - f.fields_for(:comments, []) do |cf| - concat cf.text_field(:name) - end + form_for(@post) do |f| + concat f.text_field(:title) + f.fields_for(:comments, []) do |cf| + concat cf.text_field(:name) end end - expected = whole_form do - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + end assert_dom_equal expected, output_buffer end @@ -1291,22 +1243,20 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection @post.comments = Array.new(2) { |id| Comment.new(id + 1) } - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.fields_for(:comments, @post.comments) { |cf| - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + concat f.fields_for(:comments, @post.comments) { |cf| + concat cf.text_field(:name) + } end - expected = whole_form do - '' + - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1315,22 +1265,20 @@ class FormHelperTest < ActionView::TestCase comments = Array.new(2) { |id| Comment.new(id + 1) } @post.comments = [] - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.fields_for(:comments, comments) { |cf| - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.text_field(:title) + concat f.fields_for(:comments, comments) { |cf| + concat cf.text_field(:name) + } end - expected = whole_form do - '' + - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1339,22 +1287,20 @@ class FormHelperTest < ActionView::TestCase @post.comments = [Comment.new(321), Comment.new] yielded_comments = [] - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.fields_for(:comments) { |cf| - concat cf.text_field(:name) - yielded_comments << cf.object - } - end + form_for(@post) do |f| + concat f.text_field(:title) + concat f.fields_for(:comments) { |cf| + concat cf.text_field(:name) + yielded_comments << cf.object + } end - expected = whole_form do - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer assert_equal yielded_comments, @post.comments @@ -1363,18 +1309,16 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association @post.comments = [] - assert_deprecated do - form_for(:post, @post) do |f| - concat f.fields_for(:comments, Comment.new(321), :child_index => 'abc') { |cf| - concat cf.text_field(:name) - } - end + form_for(@post) do |f| + concat f.fields_for(:comments, Comment.new(321), :child_index => 'abc') { |cf| + concat cf.text_field(:name) + } end - expected = whole_form do - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1386,43 +1330,41 @@ class FormHelperTest < ActionView::TestCase @post.tags[0].relevances = [] @post.tags[1].relevances = [] - assert_deprecated do - form_for(:post, @post) do |f| - concat f.fields_for(:comments, @post.comments[0]) { |cf| - concat cf.text_field(:name) - concat cf.fields_for(:relevances, CommentRelevance.new(314)) { |crf| - concat crf.text_field(:value) - } + form_for(@post) do |f| + concat f.fields_for(:comments, @post.comments[0]) { |cf| + concat cf.text_field(:name) + concat cf.fields_for(:relevances, CommentRelevance.new(314)) { |crf| + concat crf.text_field(:value) } - concat f.fields_for(:tags, @post.tags[0]) { |tf| - concat tf.text_field(:value) - concat tf.fields_for(:relevances, TagRelevance.new(3141)) { |trf| - concat trf.text_field(:value) - } + } + concat f.fields_for(:tags, @post.tags[0]) { |tf| + concat tf.text_field(:value) + concat tf.fields_for(:relevances, TagRelevance.new(3141)) { |trf| + concat trf.text_field(:value) } - concat f.fields_for('tags', @post.tags[1]) { |tf| - concat tf.text_field(:value) - concat tf.fields_for(:relevances, TagRelevance.new(31415)) { |trf| - concat trf.text_field(:value) - } + } + concat f.fields_for('tags', @post.tags[1]) { |tf| + concat tf.text_field(:value) + concat tf.fields_for(:relevances, TagRelevance.new(31415)) { |trf| + concat trf.text_field(:value) } - end + } end - expected = whole_form do - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + end assert_dom_equal expected, output_buffer end @@ -1550,47 +1492,40 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_and_fields_for - assert_deprecated do - form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| - concat post_form.text_field(:title) - concat post_form.text_area(:body) + form_for(@post, :as => :post, :html => { :id => 'create-post' }) do |post_form| + concat post_form.text_field(:title) + concat post_form.text_area(:body) - concat fields_for(:parent_post, @post) { |parent_fields| - concat parent_fields.check_box(:secret) - } - end + concat fields_for(:parent_post, @post) { |parent_fields| + concat parent_fields.check_box(:secret) + } end - expected = - "
" + - snowman + + expected = whole_form('/posts/123', 'create-post', 'post_edit', :method => 'put') do "" + "" + "" + - "" + - "
" + "" + end assert_dom_equal expected, output_buffer end def test_form_for_and_fields_for_with_object - assert_deprecated do - form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| - concat post_form.text_field(:title) - concat post_form.text_area(:body) + form_for(@post, :as => :post, :html => { :id => 'create-post' }) do |post_form| + concat post_form.text_field(:title) + concat post_form.text_area(:body) - concat post_form.fields_for(@comment) { |comment_fields| - concat comment_fields.text_field(:name) - } - end + concat post_form.fields_for(@comment) { |comment_fields| + concat comment_fields.text_field(:name) + } end - expected = - whole_form("/", "create-post") do - "" + - "" + - "" - end + expected = whole_form('/posts/123', 'create-post', 'post_edit', :method => 'put') do + "" + + "" + + "" + end assert_dom_equal expected, output_buffer end @@ -1606,19 +1541,17 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_labelled_builder - assert_deprecated do - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + form_for(@post, :builder => LabelledFormBuilder) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) end - expected = whole_form do - "
" + - "
" + - "
" - end + expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', :method => 'put') do + "
" + + "
" + + "
" + end assert_dom_equal expected, output_buffer end @@ -1630,8 +1563,9 @@ class FormHelperTest < ActionView::TestCase txt << %{} end - def form_text(action = "/", id = nil, html_class = nil, remote = nil) + def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil) txt = %{
" + form_text(action, id, html_class, remote, multipart) + snowman(method) + contents + "
" end def test_default_form_builder old_default_form_builder, ActionView::Base.default_form_builder = ActionView::Base.default_form_builder, LabelledFormBuilder - assert_deprecated do - form_for(:post, @post) do |f| - concat f.text_field(:title) - concat f.text_area(:body) - concat f.check_box(:secret) - end + form_for(@post) 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', 'edit_post_123', 'edit_post', :method => 'put') do "
" + "
" + "
" @@ -1691,12 +1623,10 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_labelled_builder_with_nested_fields_for_without_options_hash klass = nil - assert_deprecated do - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new) do |nested_fields| - klass = nested_fields.class - '' - end + form_for(@post, :builder => LabelledFormBuilder) do |f| + f.fields_for(:comments, Comment.new) do |nested_fields| + klass = nested_fields.class + '' end end @@ -1706,12 +1636,10 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_labelled_builder_with_nested_fields_for_with_options_hash klass = nil - assert_deprecated do - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, :index => 'foo') do |nested_fields| - klass = nested_fields.class - '' - end + form_for(@post, :builder => LabelledFormBuilder) do |f| + f.fields_for(:comments, Comment.new, :index => 'foo') do |nested_fields| + klass = nested_fields.class + '' end end @@ -1723,12 +1651,10 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_labelled_builder_with_nested_fields_for_with_custom_builder klass = nil - assert_deprecated do - form_for(:post, @post, :builder => LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, :builder => LabelledFormBuilderSubclass) do |nested_fields| - klass = nested_fields.class - '' - end + form_for(@post, :builder => LabelledFormBuilder) do |f| + f.fields_for(:comments, Comment.new, :builder => LabelledFormBuilderSubclass) do |nested_fields| + klass = nested_fields.class + '' end end @@ -1736,39 +1662,29 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_html_options_adds_options_to_form_tag - assert_deprecated do - form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end - end - expected = whole_form("/", "some_form", "some_class") + form_for(@post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end + expected = whole_form("/posts/123", "some_form", "some_class", 'put') assert_dom_equal expected, output_buffer end def test_form_for_with_string_url_option - assert_deprecated do - form_for(:post, @post, :url => 'http://www.otherdomain.com') do |f| end - end + form_for(@post, :url => 'http://www.otherdomain.com') do |f| end - assert_equal whole_form("http://www.otherdomain.com"), output_buffer - # assert_equal '
', output_buffer + assert_equal whole_form("http://www.otherdomain.com", 'edit_post_123', 'edit_post', 'put'), output_buffer end def test_form_for_with_hash_url_option - assert_deprecated do - form_for(:post, @post, :url => {:controller => 'controller', :action => 'action'}) do |f| end - end + form_for(@post, :url => {:controller => 'controller', :action => 'action'}) do |f| end assert_equal 'controller', @url_for_options[:controller] assert_equal 'action', @url_for_options[:action] end def test_form_for_with_record_url_option - assert_deprecated do - form_for(:post, @post, :url => @post) do |f| end - end + form_for(@post, :url => @post) do |f| end - expected = whole_form("/posts/123") - # expected = "
" + expected = whole_form("/posts/123", 'edit_post_123', 'edit_post', 'put') assert_equal expected, output_buffer end -- cgit v1.2.3