X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Froutes.t;h=52296eceea43ff87ad9eabb02c0dd7096a17b834;hb=6135b6b4c098a3a5862f2b690cda638d38d6b162;hp=25591bcd81e9fa47ad0047250925ff8c6007b890;hpb=73bef299767c2f6cd268a87c2afb86b69cd9349e;p=catagits%2FCatalystX-Routes.git diff --git a/t/routes.t b/t/routes.t index 25591bc..52296ec 100644 --- a/t/routes.t +++ b/t/routes.t @@ -15,7 +15,7 @@ use HTTP::Request::Common qw( GET PUT POST DELETE ); 'GET request for /foo went to the right sub' ); - request( GET '/foo', ( Accept => '*/*', ) ); + request( GET '/foo', ( Accept => '*/*' ) ); is( $MyApp1::Controller::C1::REQ{get_html}, 1, @@ -82,7 +82,7 @@ use HTTP::Request::Common qw( GET PUT POST DELETE ); } { - get('/chain1/42/chain2/84/baz/foo'); + request( GET '/chain1/42/chain2/84/baz/foo' ); is( $MyApp1::Controller::C1::REQ{chain1}, 42, @@ -101,7 +101,35 @@ use HTTP::Request::Common qw( GET PUT POST DELETE ); } { - get('/normal'); + request( GET '/user/99' ); + + is( + $MyApp1::Controller::C1::REQ{user}, 99, + 'get /user/99 calls _set_user chain point' + ); + + is( + $MyApp1::Controller::C1::REQ{user_end}, 99, + 'get /user/99 calls get chained from _set_user' + ); +} + +{ + request( GET '/thing/99' ); + + is( + $MyApp1::Controller::C1::REQ{thing}, 99, + 'get /thing/99 calls _set_thing chain point' + ); + + is( + $MyApp1::Controller::C1::REQ{thing_end}, 99, + 'get /thing/99 calls get chained from _set_thing' + ); +} + +{ + request( GET '/normal' ); is( $MyApp1::Controller::C1::REQ{normal}, 1, @@ -116,4 +144,20 @@ use HTTP::Request::Common qw( GET PUT POST DELETE ); ); } +{ + request( GET '/' ); + + is( + $MyApp1::Controller::Root::REQ{root}, 1, + 'GET request for / went to the right sub (routes work when namespace is empty string)' + ); + + request( GET '/foo.txt' ); + + is( + $MyApp1::Controller::Root::REQ{'foo.txt'}, 1, + 'GET request for /foo.txt went to the right sub (routes work when namespace is empty string)' + ); +} + done_testing();