From 56fb60ebfe9a20ced1366f3e35b2f9bd0bac8e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 16 Mar 2010 23:35:45 +0100 Subject: Fix rendering of HTML partials inside JS templates [#4197 status:resolved] --- actionpack/test/controller/new_base/render_rjs_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/test/controller/new_base/render_rjs_test.rb') diff --git a/actionpack/test/controller/new_base/render_rjs_test.rb b/actionpack/test/controller/new_base/render_rjs_test.rb index f4516ade63..7c8f1cb869 100644 --- a/actionpack/test/controller/new_base/render_rjs_test.rb +++ b/actionpack/test/controller/new_base/render_rjs_test.rb @@ -5,8 +5,10 @@ module RenderRjs self.view_paths = [ActionView::FixtureResolver.new( "render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')", "render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'", + "render_rjs/basic/index_no_js.js.rjs" => "page[:developer].replace_html render(:partial => 'developer')", "render_rjs/basic/_customer.js.erb" => "JS Partial", "render_rjs/basic/_customer.html.erb" => "HTML Partial", + "render_rjs/basic/_developer.html.erb" => "HTML Partial", "render_rjs/basic/index_locale.js.rjs" => "page[:customer].replace_html :partial => 'customer'", "render_rjs/basic/_customer.da.html.erb" => "Danish HTML Partial", "render_rjs/basic/_customer.da.js.erb" => "Danish JS Partial" @@ -37,6 +39,11 @@ module RenderRjs assert_response("$(\"customer\").update(\"JS Partial\");") end + test "rendering a partial in an RJS template should pick the HTML one if no JS is available" do + get :index_no_js, "format" => "js" + assert_response("$(\"developer\").update(\"HTML Partial\");") + end + test "replacing an element with a partial in an RJS template should pick the HTML template over the JS one" do get :index_html, "format" => "js" assert_response("$(\"customer\").update(\"HTML Partial\");") -- cgit v1.2.3 From f28d856cece877d1b2f306f54aeb12cce1db1023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 19 Mar 2010 17:20:15 +0100 Subject: Improve performance of the rendering stack by freezing formats as a sign that they shouldn't be further modified. --- actionpack/test/controller/new_base/render_rjs_test.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller/new_base/render_rjs_test.rb') diff --git a/actionpack/test/controller/new_base/render_rjs_test.rb b/actionpack/test/controller/new_base/render_rjs_test.rb index 7c8f1cb869..b602b9f8e9 100644 --- a/actionpack/test/controller/new_base/render_rjs_test.rb +++ b/actionpack/test/controller/new_base/render_rjs_test.rb @@ -5,7 +5,7 @@ module RenderRjs self.view_paths = [ActionView::FixtureResolver.new( "render_rjs/basic/index.js.rjs" => "page[:customer].replace_html render(:partial => 'customer')", "render_rjs/basic/index_html.js.rjs" => "page[:customer].replace_html :partial => 'customer'", - "render_rjs/basic/index_no_js.js.rjs" => "page[:developer].replace_html render(:partial => 'developer')", + "render_rjs/basic/index_no_js.js.erb" => "<%= render(:partial => 'developer') %>", "render_rjs/basic/_customer.js.erb" => "JS Partial", "render_rjs/basic/_customer.html.erb" => "HTML Partial", "render_rjs/basic/_developer.html.erb" => "HTML Partial", @@ -18,6 +18,12 @@ module RenderRjs render end + def index_respond_to + respond_to do |format| + format.js { render :action => "index_no_js" } + end + end + def index_locale self.locale = :da end @@ -41,7 +47,12 @@ module RenderRjs test "rendering a partial in an RJS template should pick the HTML one if no JS is available" do get :index_no_js, "format" => "js" - assert_response("$(\"developer\").update(\"HTML Partial\");") + assert_response("HTML Partial") + end + + test "rendering a partial in an RJS template should pick the HTML one if no JS is available on respond_to" do + get :index_respond_to, "format" => "js" + assert_response("HTML Partial") end test "replacing an element with a partial in an RJS template should pick the HTML template over the JS one" do -- cgit v1.2.3