Permalink
Browse files

last named route wins. fixes #4164

This differs from route recognition where first recognized route wins.
This will not be supported in Rails 4.0 so that route recognition and
generation rules are consistent.
  • Loading branch information...
1 parent 7a80ac0 commit 50af25ba87a0814d9c38984218c5e157a07f86cd @tenderlove tenderlove committed Dec 29, 2011
Showing with 41 additions and 1 deletion.
  1. +40 −0 actionpack/test/controller/base_test.rb
  2. +1 −1 actionpack/test/dispatch/routing_test.rb
@@ -197,6 +197,46 @@ def setup
rescue_action_in_public!
end
+ def test_path_generation_priority
+ rs = ActionDispatch::Routing::RouteSet.new
+ rs.draw do
+ resources :models
+ match 'special' => 'model#new', :as => :new_model
+ end
+
+ url_params = {
+ :action => "new",
+ :controller => "model",
+ :use_route => "new_model",
+ :only_path => true }
+
+ x = Struct.new(:rs, :params, :tc) {
+ include rs.named_routes.module
+ public :new_model_path
+
+ def url_for(*args)
+ tc.assert_equal([params], args)
+ rs.url_for(*args)
+ end
+ }.new(rs, url_params, self)
+ end
+
+ def test_url_for_params_priority
+ rs = ActionDispatch::Routing::RouteSet.new
+ rs.draw do
+ resources :models
+ match 'special' => 'model#new', :as => :new_model
+ end
+
+ url_params = {
+ :action => "new",
+ :controller => "model",
+ :use_route => "new_model",
+ :only_path => true }
+
+ assert_equal '/special', rs.url_for(url_params)
+ end
+
def test_url_options_override
with_routing do |set|
set.draw do
@@ -2297,7 +2297,7 @@ def test_nested_resource_constraints
def test_named_routes_collision_is_avoided_unless_explicitly_given_as
assert_equal "/c/1", routes_collision_path(1)
- assert_equal "/fc", routes_forced_collision_path
+ assert_equal "/forced_collision", routes_forced_collision_path
end
def test_redirect_argument_error

0 comments on commit 50af25b

Please sign in to comment.