Improved test about chained actions and add note in Changes.
Ferruccio Zamuner [Sun, 5 Dec 2010 23:08:01 +0000 (23:08 +0000)]
Changes
t/aggregate/live__component_controller_action_chained2.t
t/lib/ChainedActionsApp/Controller/Root.pm

diff --git a/Changes b/Changes
index f79077e..537dbf4 100644 (file)
--- 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
index 64caeea..199db81 100644 (file)
@@ -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;
index a50faa1..a436087 100644 (file)
@@ -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' );