aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-01-16 02:01:57 +0000
committerMichael Koziarski <michael@koziarski.com>2008-01-16 02:01:57 +0000
commitb812b236876ab7a6bd1f3e58a1aa71847394f3a1 (patch)
tree28e65251aee0a1007bec37b03c4ae2b5c41ff293 /actionpack/test
parent8a71f870093ccdfa0b04e318cca0f517576be380 (diff)
downloadrails-b812b236876ab7a6bd1f3e58a1aa71847394f3a1.tar.gz
rails-b812b236876ab7a6bd1f3e58a1aa71847394f3a1.tar.bz2
rails-b812b236876ab7a6bd1f3e58a1aa71847394f3a1.zip
Make render :partial recognise form builders and use the _form partial. Closes #10814 [djanowski]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8646 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/new_render_test.rb23
-rw-r--r--actionpack/test/fixtures/test/_form.erb1
-rw-r--r--actionpack/test/fixtures/test/_labelling_form.erb1
3 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index e06737ee0b..eb19b2e391 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -17,6 +17,9 @@ module NewRenderTestHelper
end
end
+class LabellingFormBuilder < ActionView::Helpers::FormBuilder
+end
+
class NewRenderTestController < ActionController::Base
layout :determine_layout
@@ -136,7 +139,15 @@ class NewRenderTestController < ActionController::Base
def partial_with_locals
render :partial => "customer", :locals => { :customer => Customer.new("david") }
end
+
+ def partial_with_form_builder
+ render :partial => ActionView::Helpers::FormBuilder.new(:post, nil, @template, nil, Proc.new {})
+ end
+ def partial_with_form_builder_subclass
+ render :partial => LabellingFormBuilder.new(:post, nil, @template, nil, Proc.new {})
+ end
+
def partial_collection
render :partial => "customer", :collection => [ Customer.new("david"), Customer.new("mary") ]
end
@@ -685,6 +696,18 @@ EOS
assert_equal "Hello: david", @response.body
end
+ def test_partial_with_form_builder
+ get :partial_with_form_builder
+ assert_match(/<label/, @response.body)
+ assert_template('test/_form')
+ end
+
+ def test_partial_with_form_builder_subclass
+ get :partial_with_form_builder_subclass
+ assert_match(/<label/, @response.body)
+ assert_template('test/_labelling_form')
+ end
+
def test_partial_collection
get :partial_collection
assert_equal "Hello: davidHello: mary", @response.body
diff --git a/actionpack/test/fixtures/test/_form.erb b/actionpack/test/fixtures/test/_form.erb
new file mode 100644
index 0000000000..01107f1cb2
--- /dev/null
+++ b/actionpack/test/fixtures/test/_form.erb
@@ -0,0 +1 @@
+<%= form.label :title %>
diff --git a/actionpack/test/fixtures/test/_labelling_form.erb b/actionpack/test/fixtures/test/_labelling_form.erb
new file mode 100644
index 0000000000..1b95763165
--- /dev/null
+++ b/actionpack/test/fixtures/test/_labelling_form.erb
@@ -0,0 +1 @@
+<%= labelling_form.label :title %>