Adding tests for non-optional glob parameters

This commit is contained in:
Andrew White 2012-02-26 00:33:15 +00:00
parent cbe74cf024
commit 74bc920e84
1 changed files with 27 additions and 2 deletions

View File

@ -146,6 +146,31 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
end
def test_star_paths_are_greedy
rs.draw do
match "/*path", :to => lambda { |env|
x = env["action_dispatch.request.path_parameters"][:path]
[200, {}, [x]]
}, :format => false
end
u = URI('http://example.org/foo/bar.html')
assert_equal u.path.sub(/^\//, ''), get(u)
end
def test_star_paths_are_greedy_but_not_too_much
rs.draw do
match "/*path", :to => lambda { |env|
x = JSON.dump env["action_dispatch.request.path_parameters"]
[200, {}, [x]]
}
end
expected = { "path" => "foo/bar", "format" => "html" }
u = URI('http://example.org/foo/bar.html')
assert_equal expected, JSON.parse(get(u))
end
def test_optional_star_paths_are_greedy
rs.draw do
match "/(*filters)", :to => lambda { |env|
x = env["action_dispatch.request.path_parameters"][:filters]
@ -157,9 +182,9 @@ class LegacyRouteSetTests < ActiveSupport::TestCase
assert_equal u.path.sub(/^\//, ''), get(u)
end
def test_star_paths_are_greedy_but_not_too_much
def test_optional_star_paths_are_greedy_but_not_too_much
rs.draw do
match "/(*filters).:format", :to => lambda { |env|
match "/(*filters)", :to => lambda { |env|
x = JSON.dump env["action_dispatch.request.path_parameters"]
[200, {}, [x]]
}