Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make controller_path available as an instance method. Closes #5724.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 12ab93b72b4f98fb2e6ce9102ff9fb2cdb6c992b 1 parent 604eb8a
@jeremy jeremy authored
View
2  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.]
View
5 actionpack/lib/action_controller/base.rb
@@ -498,6 +498,11 @@ def controller_class_name
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
View
6 actionpack/test/controller/base_test.rb
@@ -36,7 +36,9 @@ def hidden_action
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 @@ def setup
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
Please sign in to comment.
Something went wrong with that request. Please try again.