aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-02-26 00:33:15 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2012-02-26 00:33:15 +0000
commit74bc920e84b985724a93c10a3ff21090ed1b9f8e (patch)
tree124292ca140c5bcd9b1a8828d1837637e5aa4922
parentcbe74cf024f550d08c8b7f8ec0e5e5f90a1772f6 (diff)
downloadrails-74bc920e84b985724a93c10a3ff21090ed1b9f8e.tar.gz
rails-74bc920e84b985724a93c10a3ff21090ed1b9f8e.tar.bz2
rails-74bc920e84b985724a93c10a3ff21090ed1b9f8e.zip
Adding tests for non-optional glob parameters
-rw-r--r--actionpack/test/controller/routing_test.rb29
1 files changed, 27 insertions, 2 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 807905c7b5..843ae1a813 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -147,6 +147,31 @@ class LegacyRouteSetTests < ActiveSupport::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]]
@@ -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]]
}