diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-06-10 23:53:30 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-06-10 23:55:04 +0100 |
commit | 0ad0bdc01c4fe2d66dd2b405433186824e7ce136 (patch) | |
tree | 841fe23e7a1a0d2dbda2fa8da2d092d32693d8b3 /actionpack | |
parent | b440aeb54a969ec25228881dd02eb019bbfd7c1e (diff) | |
download | rails-0ad0bdc01c4fe2d66dd2b405433186824e7ce136.tar.gz rails-0ad0bdc01c4fe2d66dd2b405433186824e7ce136.tar.bz2 rails-0ad0bdc01c4fe2d66dd2b405433186824e7ce136.zip |
Delegate ActionView::Base#controller_name to controller
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/new_render_test.rb | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index eeebf335dc..c417cc07ac 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -184,7 +184,7 @@ module ActionView #:nodoc: 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 diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 6b83b8337e..b77b3ceffa 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -220,7 +220,7 @@ class NewRenderTestController < ActionController::Base 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" @@ -251,11 +251,15 @@ class NewRenderTestController < ActionController::Base 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 @@ -559,12 +563,17 @@ class NewRenderTest < Test::Unit::TestCase 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 |