aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-05-15 03:13:32 +0000
committerRick Olson <technoweenie@gmail.com>2007-05-15 03:13:32 +0000
commit80074cb4de2e60cd771b76d396d61e5c4bc0aff6 (patch)
treef8d6991a146e1268750f2be8b1e3ff62e9dbbc98
parentf8273e430916f8c7b0d21ad14aab90e427f8c0a6 (diff)
downloadrails-80074cb4de2e60cd771b76d396d61e5c4bc0aff6.tar.gz
rails-80074cb4de2e60cd771b76d396d61e5c4bc0aff6.tar.bz2
rails-80074cb4de2e60cd771b76d396d61e5c4bc0aff6.zip
Assume that rendered partials go by the HTML format by default
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6734 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG12
-rw-r--r--actionpack/lib/action_view/base.rb14
-rw-r--r--actionpack/test/controller/render_test.rb19
-rw-r--r--actionpack/test/fixtures/test/_partial.erb1
-rw-r--r--actionpack/test/fixtures/test/_partial.html.erb1
-rw-r--r--actionpack/test/fixtures/test/_partial.rhtml0
6 files changed, 34 insertions, 13 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 3d85c7b4a7..ea42f9fa5c 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,17 @@
*SVN*
+* Assume that rendered partials go by the HTML format by default
+
+ def my_partial
+ render :update do |page|
+ # in this order
+ # _foo.html.erb
+ # _foo.erb
+ # _foo.rhtml
+ page.replace :foo, :partial => 'foo'
+ end
+ end
+
* Added record identifications to FormHelper#form_for and PrototypeHelper#remote_form_for [DHH]. Examples:
<% form_for(@post) do |f| %>
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 33c71407bb..183ed75d93 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -403,19 +403,7 @@ module ActionView #:nodoc:
# symbolized version of the :format parameter of the request, or :html by default.
def template_format
- if @template_format.nil?
- @template_format =
- begin
- if controller.request.accepts.first == Mime::JS
- :js
- else
- controller.request.parameters[:format].to_sym
- end
- rescue
- :html
- end
- end
- @template_format
+ @template_format ||= controller.request.parameters[:format].to_sym rescue :html
end
def template_handler_preferences
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index d51af51454..968559fcc2 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -132,6 +132,16 @@ class TestController < ActionController::Base
@foo = render_to_string :inline => "this is a test"
end
+ def partial
+ render :partial => 'partial'
+ end
+
+ def partial_as_rjs
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+
def rescue_action(e) raise end
private
@@ -368,6 +378,15 @@ class RenderTest < Test::Unit::TestCase
assert_equal '<test>passed formatted html erb</test>', @response.body
end
+ def test_should_render_html_formatted_partial
+ get :partial
+ assert_equal 'partial html', @response.body
+ end
+
+ def test_should_render_html_formatted_partial_with_rjs
+ xhr :get, :partial_as_rjs
+ assert_equal %(Element.replace("foo", "partial html");), @response.body
+ end
protected
def assert_deprecated_render(&block)
diff --git a/actionpack/test/fixtures/test/_partial.erb b/actionpack/test/fixtures/test/_partial.erb
new file mode 100644
index 0000000000..e466dcbd8e
--- /dev/null
+++ b/actionpack/test/fixtures/test/_partial.erb
@@ -0,0 +1 @@
+invalid \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_partial.html.erb b/actionpack/test/fixtures/test/_partial.html.erb
new file mode 100644
index 0000000000..e39f6c9827
--- /dev/null
+++ b/actionpack/test/fixtures/test/_partial.html.erb
@@ -0,0 +1 @@
+partial html \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/_partial.rhtml b/actionpack/test/fixtures/test/_partial.rhtml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/actionpack/test/fixtures/test/_partial.rhtml