diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-15 20:38:39 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-15 20:38:39 +0000 |
commit | 494d2c631bbfacd6d67c5c502422c2502c2fcd3a (patch) | |
tree | 73c1cae29293cd7aad7f6834677806e19a9430ae /actionpack | |
parent | 41ef9211a2f45eee0960f677f853de7ff1ad97c8 (diff) | |
download | rails-494d2c631bbfacd6d67c5c502422c2502c2fcd3a.tar.gz rails-494d2c631bbfacd6d67c5c502422c2502c2fcd3a.tar.bz2 rails-494d2c631bbfacd6d67c5c502422c2502c2fcd3a.zip |
root_path returns '/' not ''. Closes #9563.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7482 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/routing_optimisation.rb | 11 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 11 |
3 files changed, 17 insertions, 7 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 0a727f4016..6b2f30f1b1 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* root_path returns '/' not ''. #9563 [lifofifo] + * Fixed that setting request.format should also affect respond_to blocks [DHH] * Add option to force binary mode on tempfile used for fixture_file_upload. #6380 [Jonathan Viney] diff --git a/actionpack/lib/action_controller/routing_optimisation.rb b/actionpack/lib/action_controller/routing_optimisation.rb index 535f1bed63..1b447b17e7 100644 --- a/actionpack/lib/action_controller/routing_optimisation.rb +++ b/actionpack/lib/action_controller/routing_optimisation.rb @@ -62,11 +62,10 @@ module ActionController elements << '#{request.host_with_port}' end - # 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 - route.segments[0..-2].each do |segment| + # 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. + ((route.segments.size == 1 && kind == :path) ? route.segments : route.segments[0..-2]).each do |segment| if segment.is_a?(DynamicSegment) elements << "\#{URI.escape(args[#{idx}].to_param, ActionController::Routing::Segment::UNSAFE_PCHAR)}" idx += 1 @@ -96,4 +95,4 @@ module ActionController OPTIMISERS = [PositionalArguments, PositionalArgumentsWithAdditionalParams] end end -end
\ No newline at end of file +end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 4901c93a60..fee1ad3ccf 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -218,7 +218,16 @@ class LegacyRouteSetTests < Test::Unit::TestCase map.normal ':controller/:action/:id' end end - + + def test_named_route_root + rs.draw do |map| + map.root :controller => "hello" + end + x = setup_for_named_route + assert_equal("http://named.route.test", x.send(:root_url)) + assert_equal("/", x.send(:root_path)) + end + def test_named_route_with_regexps rs.draw do |map| map.article 'page/:year/:month/:day/:title', :controller => 'page', :action => 'show', |