Browse files

Adding tests for non-optional glob parameters

  • Loading branch information...
1 parent b229bc7 commit b8c4f2d54562eb6eab46ab7b59b3ea348636e9d5 @pixeltrix pixeltrix committed Feb 26, 2012
Showing with 27 additions and 2 deletions.
  1. +27 −2 actionpack/test/controller/routing_test.rb
View
29 actionpack/test/controller/routing_test.rb
@@ -157,6 +157,31 @@ def test_pre_dash_with_custom_regexp
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]
[200, {}, [x]]
@@ -167,9 +192,9 @@ def test_star_paths_are_greedy
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]]
}

0 comments on commit b8c4f2d

Please sign in to comment.