提交 f4bfacb2 编写于 作者: N Nicholas Seckar

Enable routes to recognize uppercase controller names. Closes #1635


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1765 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 5727dc2f
......@@ -210,7 +210,7 @@ def traverse_to_controller(segments, start_at = 0)
mod_name = controller_name = segment = nil
while index < length
return nil unless /^[a-z][a-z\d_]*$/ =~ (segment = segments[index])
return nil unless /^[A-Za-z][A-Za-z\d_]*$/ =~ (segment = segments[index])
index += 1
mod_name = segment.camelize
......
......@@ -109,6 +109,9 @@ def self.const_available?(*args)
class UserController
end
class NewsFeedController
end
end
end
......@@ -718,6 +721,15 @@ def test_backwards
def test_action_expiry
assert_equal ['/content', {}], rs.generate({:controller => 'content'}, {:controller => 'content', :action => 'show'})
end
def test_recognition_with_uppercase_controller_name
assert_equal({'controller' => ::Controllers::ContentController, 'action' => 'index'}, rs.recognize_path(%w(Content)))
assert_equal({'controller' => ::Controllers::ContentController, 'action' => 'list'}, rs.recognize_path(%w(Content list)))
assert_equal({'controller' => ::Controllers::ContentController, 'action' => 'show', 'id' => '10'}, rs.recognize_path(%w(Content show 10)))
assert_equal({'controller' => ::Controllers::Admin::NewsFeedController, 'action' => 'index'}, rs.recognize_path(%w(Admin NewsFeed)))
assert_equal({'controller' => ::Controllers::Admin::NewsFeedController, 'action' => 'index'}, rs.recognize_path(%w(Admin News_Feed)))
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册