diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-18 17:03:08 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-18 17:03:08 -0700 |
commit | 2363aafca4e4c4e92d0ffb5934bab323bf633d1c (patch) | |
tree | 9d51cf31b3006f1e63e58e610be5a37ad7e2712f /actionpack | |
parent | ffcecf2fb284a32712c4e1aab65d0d11824c4b36 (diff) | |
parent | 4717c2ffc6c2416cfbf5fb560689606eadd3b3c6 (diff) | |
download | rails-2363aafca4e4c4e92d0ffb5934bab323bf633d1c.tar.gz rails-2363aafca4e4c4e92d0ffb5934bab323bf633d1c.tar.bz2 rails-2363aafca4e4c4e92d0ffb5934bab323bf633d1c.zip |
Merge pull request #6649 from route/logger_in_metal_3_2
Logger in metal backport for 3.2
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/helpers/controller_helper.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 17 |
2 files changed, 21 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/helpers/controller_helper.rb b/actionpack/lib/action_view/helpers/controller_helper.rb index 1a583e62ae..74ef25f7c1 100644 --- a/actionpack/lib/action_view/helpers/controller_helper.rb +++ b/actionpack/lib/action_view/helpers/controller_helper.rb @@ -10,14 +10,16 @@ module ActionView delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers, :flash, :action_name, :controller_name, :controller_path, :to => :controller - delegate :logger, :to => :controller, :allow_nil => true - def assign_controller(controller) if @_controller = controller @_request = controller.request if controller.respond_to?(:request) @_config = controller.config.inheritable_copy if controller.respond_to?(:config) end end + + def logger + controller.logger if controller.respond_to?(:logger) + end end end end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index b4ef22ecf7..4ad9c64413 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -718,6 +718,14 @@ class TestController < ActionController::Base end end +class MetalTestController < ActionController::Metal + include ActionController::Rendering + + def accessing_logger_in_template + render :inline => "<%= logger.class %>" + end +end + class RenderTest < ActionController::TestCase tests TestController @@ -1583,3 +1591,12 @@ class LastModifiedRenderTest < ActionController::TestCase assert_response :success end end + +class MetalRenderTest < ActionController::TestCase + tests MetalTestController + + def test_access_to_logger_in_view + get :accessing_logger_in_template + assert_equal "NilClass", @response.body + end +end |