Permalink
Browse files

Never end generated paths with a '/' #683

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@717 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed Feb 20, 2005
1 parent d8739bd commit f153f42469ff6d3791e25cdf095986909e679dde
@@ -74,8 +74,6 @@ def generate(options, defaults={})
end
components.collect! {|c| c.to_s}
- components.unshift(components.shift + '/') if components.length == 1 && @items.first == :controller # Add '/' to controllers
-
return components, unused
end
@@ -42,7 +42,7 @@ def rewrite_path(options)
RESERVED_OPTIONS.each {|k| options.delete k}
path, extras = Routing::Routes.generate(options, @request)
- path = "/#{path.join('/')}"
+ path = "/#{path.join('/')}".chomp '/'
path += build_query_string(extras)
return path
@@ -135,4 +135,4 @@ def build_query_string(hash)
return query_string
end
end
-end
+end
@@ -137,12 +137,12 @@ def test_recognize_default_nested
verify_recognize('admin/user', {:controller => 'admin/user', :action => 'index'})
end
def test_generate_default_nested_no_extras
- verify_generate('admin/user/', {}, {:controller => 'admin/user'}, @defaults)
- verify_generate('admin/user/', {}, {:controller => 'admin/user'}, @defaults)
+ verify_generate('admin/user', {}, {:controller => 'admin/user'}, @defaults)
+ verify_generate('admin/user', {}, {:controller => 'admin/user'}, @defaults)
end
def test_generate_default_nested
- verify_generate('admin/user/', {:a => 'a'}, {:controller => 'admin/user', :a => 'a'}, @defaults)
- verify_generate('admin/user/', {:a => 'a'}, {:controller => 'admin/user', :a => 'a'}, @defaults)
+ verify_generate('admin/user', {:a => 'a'}, {:controller => 'admin/user', :a => 'a'}, @defaults)
+ verify_generate('admin/user', {:a => 'a'}, {:controller => 'admin/user', :a => 'a'}, @defaults)
end
# Test generate with a default controller set.
@@ -429,16 +429,16 @@ def test_generate_typical_controller_action_path
end
def test_generate_typical_controller_index_path_explicit_index
typical_request
- verify_generate('content/', {:controller => 'content', :action => 'index'})
+ verify_generate('content', {:controller => 'content', :action => 'index'})
end
def test_generate_typical_controller_index_path_explicit_index
typical_request
- verify_generate('content/', {:controller => 'content', :action => 'index'})
+ verify_generate('content', {:controller => 'content', :action => 'index'})
end
def test_generate_typical_controller_index_path_implicit_index
typical_request
@request.path_parameters[:controller] = 'resource'
- verify_generate('content/', {:controller => 'content'})
+ verify_generate('content', {:controller => 'content'})
end
def test_generate_no_perfect_route
@@ -480,6 +480,6 @@ def test_default_dropped_with_nil_option
class AssertionRoutingTests < Test::Unit::TestCase
def test_assert_routing
ActionController::Routing::Routes.reload rescue nil
- assert_routing('content/', {:controller => 'content', :action => 'index'})
+ assert_routing('content', {:controller => 'content', :action => 'index'})
end
end

0 comments on commit f153f42

Please sign in to comment.