From dbf82557e46b748e98a0ab6ed4ab6c823cac4dd2 Mon Sep 17 00:00:00 2001 From: Alex Chrome Date: Wed, 28 Jul 2010 14:10:39 +0700 Subject: Added :format option for form_for helper and spec for this [#5226 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionpack/test/template/form_helper_test.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index fd801e2a9e..9a1fe01872 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -641,6 +641,18 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_with_format + form_for(@post, :format => :json, :html => { :id => "edit_post_123", :class => "edit_post" }) do |f| + concat f.label(:title) + end + + expected = whole_form("/posts/123.json", "edit_post_123" , "edit_post", :method => "put") do + "" + end + + assert_dom_equal expected, output_buffer + end + def test_form_for_with_symbol_object_name form_for(@post, :as => "other_name", :html => { :id => 'create-post' }) do |f| concat f.label(:title, :class => 'post_title') @@ -1761,8 +1773,12 @@ class FormHelperTest < ActionView::TestCase "/posts" end - def post_path(post) - "/posts/#{post.id}" + def post_path(post, options = {}) + if options[:format] + "/posts/#{post.id}.#{options[:format]}" + else + "/posts/#{post.id}" + end end def protect_against_forgery? -- cgit v1.2.3