diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-28 16:33:40 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-28 16:33:40 -0800 |
commit | 50af25ba87a0814d9c38984218c5e157a07f86cd (patch) | |
tree | eb12bd3ffbf4e0a1238e0e4e114547cce798a93f /actionpack/test/controller | |
parent | 7a80ac0162ae84cf22c91646690ad18916a66274 (diff) | |
download | rails-50af25ba87a0814d9c38984218c5e157a07f86cd.tar.gz rails-50af25ba87a0814d9c38984218c5e157a07f86cd.tar.bz2 rails-50af25ba87a0814d9c38984218c5e157a07f86cd.zip |
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.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/base_test.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 9c22a4e7e0..ec8e5521c4 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -197,6 +197,46 @@ class UrlOptionsTest < ActionController::TestCase 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 |