aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb5
-rw-r--r--actionpack/test/controller/base_test.rb6
3 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index e06148c424..335fa34436 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Make controller_path available as an instance method. #5724 [jmckible@gmail.com]
+
* Update query parser to support adjacent hashes. [Nicholas Seckar]
* Make action caching aware of different formats for the same action so that, e.g. foo.xml is cached separately from foo.html. Implicitly set content type when reading in cached content with mime revealing extensions so the entire onous isn't on the webserver. [Marcel Molina Jr.]
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index fd284ae72b..339c0ceb11 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -498,6 +498,11 @@ module ActionController #:nodoc:
def controller_name
self.class.controller_name
end
+
+ # Converts the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat".
+ def controller_path
+ self.class.controller_path
+ end
def session_enabled?
request.session_options[:disabled] != false
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 1a4afcf521..588b9f60af 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -36,7 +36,9 @@ end
class ControllerClassTests < Test::Unit::TestCase
def test_controller_path
assert_equal 'empty', EmptyController.controller_path
+ assert_equal EmptyController.controller_path, EmptyController.new.controller_path
assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path
+ assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path
end
def test_controller_name
assert_equal 'empty', EmptyController.controller_name
@@ -56,10 +58,10 @@ class ControllerInstanceTests < Test::Unit::TestCase
def test_action_methods
@empty_controllers.each do |c|
- assert_equal Set.new, c.send(:action_methods), "#{c.class.controller_path} should be empty!"
+ assert_equal Set.new, c.send(:action_methods), "#{c.controller_path} should be empty!"
end
@non_empty_controllers.each do |c|
- assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.class.controller_path} should not be empty!"
+ assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.controller_path} should not be empty!"
end
end
end