From e494b0a441aab6d85a7b1cdc2c3b0d03196ada21 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Fri, 30 Jun 2006 02:36:17 +0000 Subject: 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 --- actionpack/test/controller/routing_test.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'actionpack/test/controller/routing_test.rb') 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 -- cgit v1.2.3