From cb5b8a7f055966c1f3e2d65d09c1b914e82d2c39 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 23 Sep 2007 22:52:57 +0000 Subject: Optimized named routes respect AbstractRequest.relative_url_root. Closes #9612. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7605 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/routing_test.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 9db0a4962b..d1e829390b 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -49,11 +49,13 @@ class LegacyRouteSetTests < Test::Unit::TestCase def setup # These tests assume optimisation is on, so re-enable it. ActionController::Routing.optimise_named_routes = true + @rs = ::ActionController::Routing::RouteSet.new @rs.draw {|m| m.connect ':controller/:action/:id' } + ActionController::Routing.use_controllers! %w(content admin/user admin/news_feed) end - + def test_default_setup assert_equal({:controller => "content", :action => 'index'}, rs.recognize_path("/content")) assert_equal({:controller => "content", :action => 'list'}, rs.recognize_path("/content/list")) @@ -226,7 +228,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase end x = setup_for_named_route assert_equal("http://named.route.test/", x.send(:root_url)) - assert_equal("/", x.send(:root_path)) + assert_equal("/relative/", x.send(:root_path)) end def test_named_route_with_regexps @@ -279,7 +281,7 @@ class LegacyRouteSetTests < Test::Unit::TestCase # No / to %2F in URI, only for query params. x = setup_for_named_route - assert_equal("/file/hello/world", x.send(:path_path, 'hello/world')) + assert_equal("/relative/file/hello/world", x.send(:path_path, 'hello/world')) end def test_non_controllers_cannot_be_matched @@ -918,6 +920,9 @@ uses_mocha 'RouteTest' do (subdomains * '.') + '.' + domain end + def relative_url_root + '/relative' + end end class RouteTest < Test::Unit::TestCase @@ -2010,4 +2015,4 @@ class RoutingTest < Test::Unit::TestCase assert c.ancestors.include?(h) end -end \ No newline at end of file +end -- cgit v1.2.3