mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Delegate action_name to controller inside views.
This commit is contained in:
parent
a53331a161
commit
e520fd5db7
2 changed files with 10 additions and 1 deletions
|
@ -185,7 +185,7 @@ module ActionView #:nodoc:
|
|||
attr_internal :request
|
||||
|
||||
delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers,
|
||||
:flash, :logger, :to => :controller
|
||||
:flash, :logger, :action_name, :to => :controller
|
||||
|
||||
module CompiledTemplates #:nodoc:
|
||||
# holds compiled template code
|
||||
|
|
|
@ -247,6 +247,10 @@ class NewRenderTestController < ActionController::Base
|
|||
render :inline => "<%= logger.class %>"
|
||||
end
|
||||
|
||||
def accessing_action_name_in_template
|
||||
render :inline => "<%= action_name %>"
|
||||
end
|
||||
|
||||
def accessing_params_in_template_with_layout
|
||||
render :layout => nil, :inline => "Hello: <%= params[:name] %>"
|
||||
end
|
||||
|
@ -546,6 +550,11 @@ class NewRenderTest < Test::Unit::TestCase
|
|||
assert_equal "Logger", @response.body
|
||||
end
|
||||
|
||||
def test_access_to_action_name_in_view
|
||||
get :accessing_action_name_in_template
|
||||
assert_equal "accessing_action_name_in_template", @response.body
|
||||
end
|
||||
|
||||
def test_render_xml
|
||||
get :render_xml_hello
|
||||
assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
|
||||
|
|
Loading…
Reference in a new issue