merge rafl's test
Matt S Trout [Mon, 18 Aug 2008 12:02:54 +0000 (12:02 +0000)]
t/lib/TestApp/Controller/Action/Chained.pm
t/live_component_controller_action_chained.t

index 61210dc..90b1efe 100644 (file)
@@ -175,6 +175,16 @@ sub cc_b           : Chained('cc_base')    PathPart('b')                           CaptureArgs(0) { }
 sub cc_b_link  : Chained('cc_b')               PathPart('')                            CaptureArgs(1) { }
 sub cc_b_anchor        : Chained('cc_b_link')  PathPart('anchor.html')         Args()             { }
 
+#
+#   Test static paths vs. captures
+#
+
+sub apan        : Chained('/')     CaptureArgs(0) PathPrefix   { }
+sub korv        : Chained('apan')  CaptureArgs(0) PathPart('') { }
+sub wurst       : Chained('apan')  CaptureArgs(1) PathPart('') { }
+sub static_end  : Chained('korv')  Args(0)                     { }
+sub capture_end : Chained('wurst') Args(0)        PathPart('') { }
+
 sub end :Private {
   my ($self, $c) = @_;
   return if $c->stash->{no_end};
index d2bf107..e2fed7d 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 136*$iters;
+use Test::More tests => 138*$iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -945,4 +945,23 @@ sub run_tests {
         is( $response->content, '; 1', 'Content OK' );
     }
 
+    #
+    #   static paths vs. captures
+    #
+    {
+        my @expected = qw[
+            TestApp::Controller::Action::Chained->begin
+            TestApp::Controller::Action::Chained->apan
+            TestApp::Controller::Action::Chained->korv
+            TestApp::Controller::Action::Chained->static_end
+            TestApp::Controller::Action::Chained->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        ok( my $response = request('http://localhost/action/chained/static_end'),
+            "static paths are prefered over captures" );
+        is( $response->header('X-Catalyst-Executed'),
+            $expected, 'Executed actions' );
+    }
 }