mirror of
https://github.com/github/rails.git
synced 2026-02-07 20:54:57 -05:00
Improved rendering speed on complicated templates by up to 25% #1234 [Stephan Kaes]. This did necessasitate a change to the internals of ActionView#render_template that now has four parameters. Developers of custom view handlers (like Amrita) need to update for that.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1874 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -8,5 +8,5 @@ require 'action_controller'
|
||||
require 'action_controller/test_process'
|
||||
|
||||
ActionController::Base.logger = nil
|
||||
ActionController::Base.ignore_missing_templates = true
|
||||
ActionController::Base.ignore_missing_templates = false
|
||||
ActionController::Routing::Routes.reload rescue nil
|
||||
|
||||
@@ -19,7 +19,7 @@ class CustomHandlerTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_custom_render
|
||||
result = @view.render_template( "foo", "hello <%= one %>", "one" => "two" )
|
||||
result = @view.render_template( "foo", "hello <%= one %>", nil, "one" => "two" )
|
||||
assert_equal(
|
||||
[ "hello <%= one %>", { "one" => "two" }, @view ],
|
||||
result )
|
||||
@@ -27,7 +27,7 @@ class CustomHandlerTest < Test::Unit::TestCase
|
||||
|
||||
def test_unhandled_extension
|
||||
# uses the ERb handler by default if the extension isn't recognized
|
||||
result = @view.render_template( "bar", "hello <%= one %>", "one" => "two" )
|
||||
result = @view.render_template( "bar", "hello <%= one %>", nil, "one" => "two" )
|
||||
assert_equal "hello two", result
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,6 +114,11 @@ class NewRenderTestController < ActionController::Base
|
||||
redirect_to :action => "double_render"
|
||||
end
|
||||
|
||||
def rendering_with_conflicting_local_vars
|
||||
@name = "David"
|
||||
render :action => "potential_conflicts"
|
||||
end
|
||||
|
||||
def rescue_action(e) raise end
|
||||
|
||||
private
|
||||
@@ -236,11 +241,6 @@ class NewRenderTest < Test::Unit::TestCase
|
||||
assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
|
||||
end
|
||||
|
||||
# def test_partials_list
|
||||
# get :partials_list
|
||||
# assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body
|
||||
# end
|
||||
|
||||
def test_partial_only
|
||||
get :partial_only
|
||||
assert_equal "only partial", @response.body
|
||||
@@ -287,4 +287,14 @@ class NewRenderTest < Test::Unit::TestCase
|
||||
def test_render_and_redirect
|
||||
assert_raises(ActionController::DoubleRenderError) { get :render_and_redirect }
|
||||
end
|
||||
end
|
||||
|
||||
def test_rendering_with_conflicting_local_vars
|
||||
get :rendering_with_conflicting_local_vars
|
||||
assert_equal("First: David\nSecond: Stephan\nThird: David\nFourth: David\nFifth: ", @response.body)
|
||||
end
|
||||
|
||||
# def test_partials_list
|
||||
# get :partials_list
|
||||
# assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body
|
||||
# end
|
||||
end
|
||||
@@ -5,6 +5,7 @@ class TestTest < Test::Unit::TestCase
|
||||
class TestController < ActionController::Base
|
||||
def set_flash
|
||||
flash["test"] = ">#{flash["test"]}<"
|
||||
render :text => 'ignore me'
|
||||
end
|
||||
|
||||
def test_params
|
||||
|
||||
2
actionpack/test/fixtures/test/_person.rhtml
vendored
Normal file
2
actionpack/test/fixtures/test/_person.rhtml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
Second: <%= name %>
|
||||
Third: <%= @name %>
|
||||
4
actionpack/test/fixtures/test/potential_conflicts.rhtml
vendored
Normal file
4
actionpack/test/fixtures/test/potential_conflicts.rhtml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
First: <%= @name %>
|
||||
<%= render :partial => "person", :locals => { :name => "Stephan" } -%>
|
||||
Fourth: <%= @name %>
|
||||
Fifth: <%= name %>
|
||||
Reference in New Issue
Block a user