Make sure the benchmarking render method always returns the result of the render, regardless of whether logging is enabled or not.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1371 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2005-05-30 09:00:46 +00:00
parent f57ee365e1
commit f8542a64b3
5 changed files with 26 additions and 28 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Make sure the benchmarking render method always returns the output of the render.
* render(:text), render(:partial), and render(:nothing) always default to :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action.
* verify with :redirect_to won't redirect if a redirect or render has already been performed #1350

View File

@ -20,13 +20,17 @@ module ActionController #:nodoc:
render_without_benchmark(options, deprecated_status)
else
db_runtime = ActiveRecord::Base.connection.reset_runtime if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
@rendering_runtime = Benchmark::measure{ render_without_benchmark(options, deprecated_status) }.real
render_output = nil
@rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, deprecated_status) }.real
if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
@db_rt_before_render = db_runtime
@db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
@rendering_runtime -= @db_rt_after_render
end
render_output
end
end

View File

@ -18,7 +18,9 @@ class CGI #:nodoc:
end
private
MULTIPART_FORM_BOUNDARY_RE = %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n #"
unless defined?(MULTIPART_FORM_BOUNDARY_RE)
MULTIPART_FORM_BOUNDARY_RE = %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n #"
end
def multipart_form_boundary
if env_table['REQUEST_METHOD'] == 'POST'

View File

@ -9,10 +9,12 @@ module Fun
end
end
class TestController < ActionController::Base
class NewRenderTestController < ActionController::Base
layout :determine_layout
def self.controller_name; "test"; end
def self.controller_path; "test"; end
def hello_world
end
@ -103,26 +105,17 @@ class TestController < ActionController::Base
end
end
TestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
NewRenderTestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
Fun::GamesController.template_root = File.dirname(__FILE__) + "/../fixtures/"
class TestLayoutController < ActionController::Base
layout "layouts/standard"
def hello_world
end
def hello_world_outside_layout
end
def rescue_action(e)
raise unless ActionController::MissingTemplate === e
end
end
class RenderTest < Test::Unit::TestCase
class NewRenderTest < Test::Unit::TestCase
def setup
@controller = TestController.new
@controller = NewRenderTestController.new
# enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
# a more accurate simulation of what happens in "real life".
@controller.logger = Logger.new(nil)
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@ -244,9 +237,4 @@ class RenderTest < Test::Unit::TestCase
get :accessing_params_in_template, :name => "David"
assert_equal "Hello: David", @response.body
end
private
def process_request
TestController.process(@request, @response)
end
end

View File

@ -1,6 +1,8 @@
require File.dirname(__FILE__) + '/../abstract_unit'
Customer = Struct.new("Customer", :name)
unless defined?(Customer)
Customer = Struct.new("Customer", :name)
end
module Fun
class GamesController < ActionController::Base
@ -214,4 +216,4 @@ class RenderTest < Test::Unit::TestCase
def process_request
TestController.process(@request, @response)
end
end
end