Permalink
Browse files

Allow symbols on routes declaration (:controller and :action values) [#…

…2828 state:resolved]

Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
  • Loading branch information...
1 parent 944f4fc commit 6673001a5e14ef2d342a03ae16f1da481bc01084 @blaxter blaxter committed with Yehuda Katz + Carl Lerche Jun 23, 2009
@@ -305,6 +305,7 @@ def routes_changed_at
end
def add_route(path, options = {})
+ options.each { |k, v| options[k] = v.to_s if [:controller, :action].include?(k) && v.is_a?(Symbol) }
route = builder.build(path, options)
routes << route
route
@@ -2487,6 +2487,16 @@ def test_route_requirement_recognize_with_xi_modifiers
end
assert_equal({:controller => 'pages', :action => 'show', :name => 'JAMIS'}, set.recognize_path('/page/JAMIS'))
end
+
+ def test_routes_with_symbols
+ set.draw do |map|
+ map.connect 'unnamed', :controller => :pages, :action => :show, :name => :as_symbol
+ map.named 'named', :controller => :pages, :action => :show, :name => :as_symbol
+ end
+ assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/unnamed'))
+ assert_equal({:controller => 'pages', :action => 'show', :name => :as_symbol}, set.recognize_path('/named'))
+ end
+
end
class RouteLoadingTest < Test::Unit::TestCase

0 comments on commit 6673001

Please sign in to comment.