diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-02-26 00:21:08 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-02-26 00:21:08 +0000 |
commit | b8c4f2d54562eb6eab46ab7b59b3ea348636e9d5 (patch) | |
tree | e688f740c6a2191683082c72ae77cf174bde10db /actionpack/test/controller | |
parent | b229bc70e50ec0887c5bb3aaaa9c6ee8af054026 (diff) | |
download | rails-b8c4f2d54562eb6eab46ab7b59b3ea348636e9d5.tar.gz rails-b8c4f2d54562eb6eab46ab7b59b3ea348636e9d5.tar.bz2 rails-b8c4f2d54562eb6eab46ab7b59b3ea348636e9d5.zip |
Adding tests for non-optional glob parameters
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 03eac2c5a1..e2e57ec292 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -157,6 +157,31 @@ class LegacyRouteSetTests < Test::Unit::TestCase 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 @@ class LegacyRouteSetTests < Test::Unit::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]] } |