From: Ferruccio Zamuner Date: Sun, 5 Dec 2010 23:08:01 +0000 (+0000) Subject: Improved test about chained actions and add note in Changes. X-Git-Tag: 5.80030~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=d4f76f02f299906d23b02bb4bb4007de437a8747;hp=8865ee1205d2f74a601105ae6c85af2cceb8ad7d Improved test about chained actions and add note in Changes. --- diff --git a/Changes b/Changes index f79077e..537dbf4 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,13 @@ Bug fixes: - Deal correctly with GLOB file handles in the response body (setting the Content-Length header appropriately) + - Chained dispatch has been fixed to always prefer paths + with the minimum number of captures (rather than the + maximum number of actions). This means that (for example) + a URI path /foo/* made out of 2 actions will take preference + to a URI path /*/* made out of 3 actions. Please check your applications + if you are using chained action and please write new test to report + failing case. Documentation: - Clarify that when forwarding or detaching, the end action associated diff --git a/t/aggregate/live__component_controller_action_chained2.t b/t/aggregate/live__component_controller_action_chained2.t index 64caeea..199db81 100644 --- a/t/aggregate/live__component_controller_action_chained2.t +++ b/t/aggregate/live__component_controller_action_chained2.t @@ -10,12 +10,12 @@ plan 'skip_all' if $ENV{CATALYST_SERVER}; # This is not TestApp content_like('/', qr/Application Home Page/, 'Application home'); content_like('/15/GoldFinger', qr/List project GoldFinger pages/, 'GoldFinger Project Index'); content_like('/15/GoldFinger/4/007', qr/This is 007 page of GoldFinger project/, '007 page in GoldFinger Project'); -TODO: { - local $TODO="Bug on precedence of dispatch order of chained actions."; - content_like('/account', qr/New account o login/, 'no account'); - content_like('/account/ferz', qr/This is account ferz/, 'account'); - content_like('/account/123', qr/This is account 123/, 'account'); -} + +content_like('/account', qr/New account o login/, 'no account'); +content_like('/account/ferz', qr/This is account ferz/, 'account'); +content_like('/account/123', qr/This is account 123/, 'account'); +content_like('/account/profile/007/James Bond', qr/This is profile of James Bond/, 'account'); + action_notfound('/c'); done_testing; diff --git a/t/lib/ChainedActionsApp/Controller/Root.pm b/t/lib/ChainedActionsApp/Controller/Root.pm index a50faa1..a436087 100644 --- a/t/lib/ChainedActionsApp/Controller/Root.pm +++ b/t/lib/ChainedActionsApp/Controller/Root.pm @@ -50,6 +50,16 @@ sub account : Chained('account_base') PathPart('') Args(0) { $c->response->body( "This is account " . $c->stash->{account_id} ); } +sub profile_base : Chained('setup') PathPart('account/profile') CaptureArgs(1) { + my($self,$c,$acc_id) = @_; + $c->stash({account_id=>$acc_id}); +} + +sub profile : Chained('profile_base') PathPart('') Args(1) { + my($self,$c,$acc) = @_; + $c->response->body( "This is profile of " . $acc ); +} + sub default : Chained('setup') PathPart('') Args() { my ( $self, $c ) = @_; $c->response->body( 'Page not found' );