From 5cc47e4c1926e0806897532d5d49c35df912b28c Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 14 Feb 2012 16:51:22 -0800 Subject: adding tests to document behavior for #4817 --- actionpack/test/controller/routing_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index d403494261..ee9374cc91 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -145,6 +145,32 @@ class LegacyRouteSetTests < ActiveSupport::TestCase 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 => { -- cgit v1.2.3