mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Allow symbols on routes declaration (:controller and :action values) [#2828 state:resolved]
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
This commit is contained in:
committed by
Yehuda Katz + Carl Lerche
parent
0fbf458b6c
commit
fc6077d76e
@@ -305,6 +305,7 @@ module ActionController
|
||||
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
|
||||
|
||||
@@ -2492,6 +2492,16 @@ class RouteSetTest < Test::Unit::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user