Skip to content

Commit

Permalink
adding tests to document behavior for rails#4817
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 15, 2012
1 parent 5843069 commit 5cc47e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions actionpack/test/controller/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@ def test_pre_dash_with_custom_regexp
assert_equal 'Not Found', get(URI('http://example.org/journey/omg-faithfully'))
end

def test_star_paths_are_greedy
rs.draw do
match "/(*filters)", :to => lambda { |env|
x = env["action_dispatch.request.path_parameters"][:filters]
[200, {}, [x]]
}, :format => false
end

u = URI('http://example.org/ne_27.065938,-80.6092/sw_25.489856,-82.542794')
assert_equal u.path.sub(/^\//, ''), get(u)
end

def test_star_paths_are_greedy_but_not_too_much
rs.draw do
match "/(*filters).:format", :to => lambda { |env|
x = JSON.dump env["action_dispatch.request.path_parameters"]
[200, {}, [x]]
}
end

expected = { "filters" => "ne_27.065938,-80.6092/sw_25.489856,-82",
"format" => "542794" }
u = URI('http://example.org/ne_27.065938,-80.6092/sw_25.489856,-82.542794')
assert_equal expected, JSON.parse(get(u))
end

def test_regexp_precidence
@rs.draw do
match '/whois/:domain', :constraints => {
Expand Down

0 comments on commit 5cc47e4

Please sign in to comment.