Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Optimized named routes respect AbstractRequest.relative_url_root. Clo…

…ses #9612.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7605 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit cb5b8a7f055966c1f3e2d65d09c1b914e82d2c39 1 parent ab09984
Jeremy Kemper jeremy authored
2  actionpack/CHANGELOG
View
@@ -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]
2  actionpack/lib/action_controller/routing_optimisation.rb
View
@@ -75,6 +75,8 @@ def generation_code
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.
13 actionpack/test/controller/routing_test.rb
View
@@ -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 @@ def test_named_route_root
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 @@ def test_paths_slashes_unescaped_with_ordered_parameters
# 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 @@ def host_with_port
(subdomains * '.') + '.' + domain
end
+ def relative_url_root
+ '/relative'
+ end
end
class RouteTest < Test::Unit::TestCase
@@ -2010,4 +2015,4 @@ def test_routing_helper_module
assert c.ancestors.include?(h)
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.