Skip to content

Commit

Permalink
Delegate ActionView::Base#controller_name to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Jun 10, 2008
1 parent b440aeb commit 0ad0bdc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/base.rb
Expand Up @@ -184,7 +184,7 @@ def self.cache_template_extensions=(*args)
attr_internal :request

delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers,
:flash, :logger, :action_name, :to => :controller
:flash, :logger, :action_name, :controller_name, :to => :controller

module CompiledTemplates #:nodoc:
# holds compiled template code
Expand Down
15 changes: 12 additions & 3 deletions actionpack/test/controller/new_render_test.rb
Expand Up @@ -220,7 +220,7 @@ def render_to_string_with_assigns
render :action => "test/hello_world"
end

def render_to_string_with_partial
def render_to_string_with_partial
@partial_only = render_to_string :partial => "partial_only"
@partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") }
render :action => "test/hello_world"
Expand Down Expand Up @@ -251,11 +251,15 @@ def accessing_request_in_template
def accessing_logger_in_template
render :inline => "<%= logger.class %>"
end

def accessing_action_name_in_template
render :inline => "<%= action_name %>"
end

def accessing_controller_name_in_template
render :inline => "<%= controller_name %>"
end

def accessing_params_in_template_with_layout
render :layout => nil, :inline => "Hello: <%= params[:name] %>"
end
Expand Down Expand Up @@ -559,12 +563,17 @@ def test_access_to_logger_in_view
get :accessing_logger_in_template
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_access_to_controller_name_in_view
get :accessing_controller_name_in_template
assert_equal "test", @response.body # name is explicitly set to 'test' inside the controller.
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
Expand Down

1 comment on commit 0ad0bdc

@rsl
Copy link
Contributor

@rsl rsl commented on 0ad0bdc Jun 10, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Swiss Bank is open!

Please sign in to comment.