This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

* lib/journey/formatter.rb: when generating routes, skip route

  literals (routes that do not have replacement values like
  "/:controller") when matching unnamed routes.

    rails/rails#6459

* test/test_router.rb: corresponding test

Conflicts:

	lib/journey/formatter.rb
  • Loading branch information...
1 parent 361af48 commit c70e5484551a77aac94bad1bb49831fff69df784 @tenderlove tenderlove committed Jun 14, 2012
Showing with 16 additions and 3 deletions.
  1. +10 −0 CHANGELOG.rdoc
  2. +2 −0 lib/journey/formatter.rb
  3. +4 −3 test/test_router.rb
View
@@ -1,3 +1,13 @@
+Thu Jun 14 14:03:22 2012 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * lib/journey/formatter.rb: when generating routes, skip route
+ literals (routes that do not have replacement values like
+ "/:controller") when matching unnamed routes.
+
+ https://github.com/rails/rails/issues/6459
+
+ * test/test_router.rb: corresponding test
+
Wed Feb 15 11:49:41 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/journey/formatter.rb: reject non-truthy parameters parts.
View
@@ -34,6 +34,8 @@ def generate key, name, options, recall = {}, parameterize = nil
parameterized_parts.keep_if { |_,v| v }
+ next if !name && route.requirements.empty? && route.parts.empty?
@pixeltrix

pixeltrix Aug 9, 2012

Owner

Shouldn't that be route.path.requirements.empty? otherwise it'll never be empty since it will include the defaults like :controller and :action merged in.

@pixeltrix

pixeltrix Aug 9, 2012

Owner

Actually it will be empty, but only for mounted applications - is that what the line is for? Is it there just to skip unnamed routes matching against engines?

@tenderlove

tenderlove Aug 9, 2012

Owner

Yes, I believe that is correct. This test demonstrates the use.

+
next unless verify_required_parts!(route, parameterized_parts)
z = Hash[options.to_a - data.to_a - route.defaults.to_a]
View
@@ -305,11 +305,12 @@ def test_nil_path_parts_are_ignored
end
def test_generate_slash
- path = Path::Pattern.new '/'
- @router.routes.add_route nil, path, {}, {}, {}
-
params = [ [:controller, "tasks"],
[:action, "show"] ]
+ str = Router::Strexp.new("/", Hash[params], ['/', '.', '?'], true)
+ path = Path::Pattern.new str
+
+ @router.routes.add_route nil, path, {}, {}, {}
path, _ = @formatter.generate(:path_info, nil, Hash[params], {})
assert_equal '/', path

0 comments on commit c70e548

Please sign in to comment.