From 97aaf45768e9133b84760660f02854f6aff4f450 Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Tue, 18 Nov 2008 02:21:49 -0500 Subject: [PATCH] Bugfix for rendering html partial via inline render that is called with :js format. --- actionpack/lib/action_view/base.rb | 2 +- actionpack/test/controller/render_test.rb | 14 ++++++++++++++ .../test/_partial_with_only_html_version.html.erb | 1 + 3 files changed, 16 insertions(+), 1 deletions(-) create mode 100644 actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 945246a..59da9d0 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -317,7 +317,7 @@ module ActionView #:nodoc: template elsif template = self.view_paths[template_file_name] template - elsif @_render_stack.first && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"] + elsif @_render_stack.first && @_render_stack.first.respond_to?(:format_and_extension) && template = self.view_paths["#{template_file_name}.#{@_render_stack.first.format_and_extension}"] template elsif template_format == :js && template = self.view_paths["#{template_file_name}.html"] @template_format = :html diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 5d97e90..315dc3b 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -245,6 +245,15 @@ class TestController < ActionController::Base render :inline => "<%= 'Goodbye, ' + local_name %>", :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 formatted_html_erb end @@ -933,6 +942,11 @@ class RenderTest < Test::Unit::TestCase get :accessing_local_assigns_in_inline_template, :local_name => "Local David" 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_should_render_formatted_template get :formatted_html_erb diff --git a/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb b/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb new file mode 100644 index 0000000..00e6b6d --- /dev/null +++ b/actionpack/test/fixtures/test/_partial_with_only_html_version.html.erb @@ -0,0 +1 @@ +partial with only html version \ No newline at end of file -- 1.6.0.3