mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #3861 from andyjeffries/master
Named Routes shouldn't override existing ones (currently route recognition goes with the earliest match, named routes use the latest match)
This commit is contained in:
@@ -356,7 +356,7 @@ module ActionDispatch
|
||||
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 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user