Permalink
Browse files

Refinement to avoid exceptions in traverse_to_controller

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@4457 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a12aabc commit 4e2dcbfb150d8eda0c379946c1c0dbb5b7af714d @seckar seckar committed Jun 18, 2006
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*1.12.1* (April 6th, 2005)
+* Refinement to avoid exceptions in traverse_to_controller.
+
* (Hackish) Fix loading of arbitrary files in Ruby's load path by traverse_to_controller. [Nicholas Seckar]
* Fixed that template extensions would be cached development mode #4624 [Stefan Kaes]
View
1 actionpack/lib/action_controller/routing.rb
@@ -247,6 +247,7 @@ def traverse_to_controller(segments, start_at = 0)
if mod.const_defined? mod_name
next_mod = mod.send(:const_get, mod_name)
+ next_mod = nil unless next_mod.is_a?(Module)
else
suffix = File.join(segments[start_at..index])
$:.each do |base|
View
1 actionpack/test/controller/fake_controllers.rb
@@ -6,6 +6,7 @@ class NotAController
end
module Admin
class << self; alias_method :const_available?, :const_defined?; end
+ SomeConstant = 10
class UserController < Class.new(ActionController::Base); end
class NewsFeedController < Class.new(ActionController::Base); end
end
View
4 actionpack/test/controller/routing_test.rb
@@ -982,6 +982,10 @@ def test_traverse_to_controller_should_not_load_arbitrary_files
$:[0..-1] = load_path
end
+ def test_traverse_should_not_trip_on_non_module_constants
+ assert_equal nil, ActionController::Routing::ControllerComponent.traverse_to_controller(%w(admin some_constant a))
+ end
+
end
end

0 comments on commit 4e2dcbf

Please sign in to comment.