diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-06-30 02:36:17 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-06-30 02:36:17 +0000 |
commit | e494b0a441aab6d85a7b1cdc2c3b0d03196ada21 (patch) | |
tree | 68066202b1017860706a8e38b8b66b16d982db1b /actionpack/test/controller | |
parent | 546c04c6b45ccef6dd013e169f584a80361557ca (diff) | |
download | rails-e494b0a441aab6d85a7b1cdc2c3b0d03196ada21.tar.gz rails-e494b0a441aab6d85a7b1cdc2c3b0d03196ada21.tar.bz2 rails-e494b0a441aab6d85a7b1cdc2c3b0d03196ada21.zip |
Add route_name_path method to generate only the path for a named routes. For example, map.person will add person_path.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4518 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index e6d42c823f..56070fe6f3 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1108,8 +1108,9 @@ class RouteSetTest < Test::Unit::TestCase end def url_for(options) + only_path = options.delete(:only_path) path = routes.generate(options) - "http://named.route.test#{path}" + only_path ? path : "http://named.route.test#{path}" end end @@ -1193,13 +1194,21 @@ class RouteSetTest < Test::Unit::TestCase assert_equal( { :controller => 'people', :action => 'index', :use_route => :index }, controller.send(:hash_for_index_url)) + + assert_equal( + { :controller => 'people', :action => 'show', :id => 5, :use_route => :show, :only_path => true }, + controller.send(:hash_for_show_path, :id => 5) + ) end def test_named_route_url_method controller = setup_named_route_test - + assert_equal "http://named.route.test/people/5", controller.send(:show_url, :id => 5) + assert_equal "/people/5", controller.send(:show_path, :id => 5) + assert_equal "http://named.route.test/people", controller.send(:index_url) + assert_equal "/people", controller.send(:index_path) end def test_namd_route_url_method_with_ordered_parameters |