aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-23 22:52:57 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-23 22:52:57 +0000
commitcb5b8a7f055966c1f3e2d65d09c1b914e82d2c39 (patch)
tree1da909365ccec0d80a950946e228c751effbebd6 /actionpack
parentab09984d4ac6c99cad8e984dd0d9771790fa1d1d (diff)
downloadrails-cb5b8a7f055966c1f3e2d65d09c1b914e82d2c39.tar.gz
rails-cb5b8a7f055966c1f3e2d65d09c1b914e82d2c39.tar.bz2
rails-cb5b8a7f055966c1f3e2d65d09c1b914e82d2c39.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/routing_optimisation.rb2
-rw-r--r--actionpack/test/controller/routing_test.rb13
3 files changed, 13 insertions, 4 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 8d25ff47f3..e4e717c238 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Optimized named routes respect AbstractRequest.relative_url_root. #9612 [danielmorrison, Jeremy Kemper]
+
* Introduce ActionController::Base.rescue_from to declare exception-handling methods. Cleaner style than the case-heavy rescue_action_in_public. #9449 [norbert]
* Rename some RequestForgeryProtection methods. The class method is now #protect_from_forgery, and the default parameter is now 'authenticity_token'. [Rick]
diff --git a/actionpack/lib/action_controller/routing_optimisation.rb b/actionpack/lib/action_controller/routing_optimisation.rb
index fdd5a81c19..71cfcbd935 100644
--- a/actionpack/lib/action_controller/routing_optimisation.rb
+++ b/actionpack/lib/action_controller/routing_optimisation.rb
@@ -75,6 +75,8 @@ module ActionController
elements << '#{request.host_with_port}'
end
+ elements << '#{request.relative_url_root if request && request.relative_url_root}'
+
# The last entry in route.segments appears to # *always* be a
# 'divider segment' for '/' but we have assertions to ensure that
# we don't include the trailing slashes, so skip them.
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