aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-04 17:20:51 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-04 17:20:51 -0600
commit148aff2097890a81e874a7c60bae5fa3b2a4d1fd (patch)
tree63df01cf33c7cc78958e6b192998b0259dda5892 /actionpack
parentab211bf592f52fbde7853961030046ea1d387851 (diff)
downloadrails-148aff2097890a81e874a7c60bae5fa3b2a4d1fd.tar.gz
rails-148aff2097890a81e874a7c60bae5fa3b2a4d1fd.tar.bz2
rails-148aff2097890a81e874a7c60bae5fa3b2a4d1fd.zip
Set template_format to html inside rjs templates so renders within it default to html.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/base.rb3
-rw-r--r--actionpack/lib/action_view/template_handlers/rjs.rb1
-rw-r--r--actionpack/test/controller/render_test.rb14
-rw-r--r--actionpack/test/template/render_test.rb6
4 files changed, 1 insertions, 23 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index a731fa3e1d..b8a5d39b20 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -327,9 +327,6 @@ module ActionView #:nodoc:
elsif (first_render = @_render_stack.first) && first_render.respond_to?(:format_and_extension) &&
(template = self.view_paths["#{template_file_name}.#{first_render.format_and_extension}"])
template
- elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"]
- @template_format = :html
- template
else
template = Template.new(template_path, view_paths)
diff --git a/actionpack/lib/action_view/template_handlers/rjs.rb b/actionpack/lib/action_view/template_handlers/rjs.rb
index a700655c9a..41a1fddb47 100644
--- a/actionpack/lib/action_view/template_handlers/rjs.rb
+++ b/actionpack/lib/action_view/template_handlers/rjs.rb
@@ -4,6 +4,7 @@ module ActionView
include Compilable
def compile(template)
+ "@template_format = :html;" +
"controller.response.content_type ||= Mime::JS;" +
"update_page do |page|;#{template.source}\nend"
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 795ad97863..c5496a9af5 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -246,15 +246,6 @@ class TestController < ActionController::Base
:locals => { :local_name => name }
end
- def helper_method_to_render_to_string(*args)
- render_to_string(*args)
- end
- helper_method :helper_method_to_render_to_string
-
- def render_html_only_partial_within_inline
- render :inline => "Hello world <%= helper_method_to_render_to_string :partial => 'test/partial_with_only_html_version' %>"
- end
-
def render_implicit_html_template
end
@@ -948,11 +939,6 @@ class RenderTest < ActionController::TestCase
assert_equal "Goodbye, Local David", @response.body
end
- def test_rendering_html_only_partial_within_inline_with_js
- get :render_html_only_partial_within_inline, :format => :js
- assert_equal "Hello world partial with only html version", @response.body
- end
-
def test_render_in_an_rjs_template_should_pick_html_templates_when_available
[:js, "js"].each do |format|
assert_nothing_raised do
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 9e827abbca..0387a11de2 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -137,12 +137,6 @@ module RenderTestCases
end
# TODO: The reason for this test is unclear, improve documentation
- def test_render_js_partial_and_fallback_to_erb_layout
- @view.template_format = :js
- assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" })
- end
-
- # TODO: The reason for this test is unclear, improve documentation
def test_render_missing_xml_partial_and_raise_missing_template
@view.template_format = :xml
assert_raise(ActionView::MissingTemplate) { @view.render(:partial => "test/layout_for_partial") }