Added a test for a chained bug
Andreas Marienborg [Tue, 11 Nov 2008 14:10:47 +0000 (14:10 +0000)]
t/aggregate/live_component_controller_action_chained.t
t/lib/TestApp/Controller/Action/Chained.pm

index a08c701..2e9c153 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 141*$iters;
+use Test::More tests => 143*$iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -981,4 +981,24 @@ sub run_tests {
         is( $response->header('X-Catalyst-Executed'),
             $expected, 'Executed actions' );
     }
+    
+    #
+    #   */search
+    #   doc/*
+    # 
+    #   request for doc/search should end up in doc/*
+    {
+        my @expected = qw[
+            TestApp::Controller::Action::Chained->begin
+            TestApp::Controller::Action::Chained->doc_star
+            TestApp::Controller::Action::Chained->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        ok( my $response = request('http://localhost/chained/doc/search'),
+            "we prefer static path parts earlier in the chain" );
+        is( $response->header('X-Catalyst-Executed'),
+            $expected, 'Executed actions' );
+    }
 }
index 90b1efe..6acc378 100644 (file)
@@ -185,6 +185,12 @@ sub wurst       : Chained('apan')  CaptureArgs(1) PathPart('') { }
 sub static_end  : Chained('korv')  Args(0)                     { }
 sub capture_end : Chained('wurst') Args(0)        PathPart('') { }
 
+
+# */search vs doc/*
+sub view : Chained('/') PathPart('chained') CaptureArgs(1) {}
+sub star_search : Chained('view') PathPart('search') Args(0) { }
+sub doc_star : Chained('/') PathPart('chained/doc') Args(1) {}
+
 sub end :Private {
   my ($self, $c) = @_;
   return if $c->stash->{no_end};