Permalink
Browse files

Named Routes shouldn't override existing ones (currently route recogn…

…ition goes with the earliest match, named routes use the latest match)
  • Loading branch information...
andyjeffries committed Dec 5, 2011
1 parent d4964b3 commit 71d769e3b58cb56b4b1d5143936c65be8b27c490
@@ -356,7 +356,7 @@ def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil
conditions = build_conditions(conditions, valid_conditions, path.names.map { |x| x.to_sym })
route = @set.add_route(app, path, conditions, defaults, name)
- named_routes[name] = route if name
+ named_routes[name] = route if name && !named_routes[name]
route
end
@@ -713,12 +713,12 @@ def test_named_draw
assert_equal set.routes.first, set.named_routes[:hello]
end
- def test_later_named_routes_take_precedence
+ def test_earlier_named_routes_take_precedence
set.draw do
match '/hello/world' => 'a#b', :as => 'hello'
match '/hello' => 'a#b', :as => 'hello'
end
- assert_equal set.routes.last, set.named_routes[:hello]
+ assert_equal set.routes.first, set.named_routes[:hello]
end
def setup_named_route_test

0 comments on commit 71d769e

Please sign in to comment.