Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bugfix, when matching multiple paths with `get`, `post`, ...

This problem was introduced with:

d03aa10
  • Loading branch information...
commit d5f4cac68c069a3caff1712fd967ed70a4eb52da 1 parent 078bfbf
@senny senny authored
View
9 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -589,8 +589,7 @@ def delete(*args, &block)
private
def map_method(method, args, &block)
options = args.extract_options!
- options[:via] = method
- options[:path] ||= args.first if args.first.is_a?(String)
+ options[:via] = method
match(*args, options, &block)
self
end
@@ -1381,7 +1380,11 @@ def match(path, *rest)
raise ArgumentError, "Unknown scope #{on.inspect} given to :on"
end
- paths.each { |_path| decomposed_match(_path, options.dup) }
+ paths.each do |_path|
+ route_options = options.dup
+ route_options[:path] ||= _path if _path.is_a?(String)
+ decomposed_match(_path, route_options)
+ end
self
end
View
15 actionpack/test/dispatch/routing_test.rb
@@ -1112,6 +1112,21 @@ def test_index
assert_equal 'projects#info', @response.body
end
+ def test_match_with_many_paths_containing_a_slash
+ draw do
+ get 'get/first', 'get/second', 'get/third', :to => 'get#show'
+ end
+
+ get '/get/first'
+ assert_equal 'get#show', @response.body
+
+ get '/get/second'
+ assert_equal 'get#show', @response.body
+
+ get '/get/third'
+ assert_equal 'get#show', @response.body
+ end
+
def test_match_shorthand_with_no_scope
draw do
get 'account/overview'
Please sign in to comment.
Something went wrong with that request. Please try again.