Static::Simple, added failing test for subrequest NEXT problem
Andy Grundman [Wed, 5 Oct 2005 02:01:50 +0000 (02:01 +0000)]
lib/Catalyst/Plugin/Static/Simple.pm
t/08subreq.t [new file with mode: 0644]
t/lib/TestApp.pm

index 01abfa2..b83215b 100644 (file)
@@ -46,7 +46,7 @@ sub prepare_action {
         return if ( $c->_locate_static_file );
     }
     
-    return $c->NEXT::prepare_action(@_);
+    return $c->NEXT::ACTUAL::prepare_action(@_);
 }
 
 # dispatch takes the file found during prepare_action and serves it
@@ -62,7 +62,7 @@ sub dispatch {
         return $c->_serve_static;
     }
     else {
-        return $c->NEXT::dispatch(@_);
+        return $c->NEXT::ACTUAL::dispatch(@_);
     }
 }
 
@@ -96,7 +96,7 @@ sub finalize {
         return $c->finalize_headers;
     }
     
-    return $c->NEXT::finalize(@_);
+    return $c->NEXT::ACTUAL::finalize(@_);
 }
 
 sub setup {
diff --git a/t/08subreq.t b/t/08subreq.t
new file mode 100644 (file)
index 0000000..bd3f06c
--- /dev/null
@@ -0,0 +1,20 @@
+#!perl\r
+\r
+use strict;\r
+use warnings;\r
+\r
+use FindBin;\r
+use lib "$FindBin::Bin/lib";\r
+\r
+use Test::More tests => 2;\r
+use Catalyst::Test 'TestApp';\r
+\r
+SKIP:\r
+{\r
+    if ( ! TestApp->isa('Catalyst::Plugin::SubRequest') ) {\r
+        skip "Install the SubRequest plugin for these tests", 2;\r
+    }\r
+\r
+    ok( my $res = request('http://localhost/subtest'), 'Request' );\r
+    is( $res->content, 'subtest2 ok', 'SubRequest ok' );\r
+}\r
index ff23ab8..a419d10 100644 (file)
@@ -9,7 +9,13 @@ TestApp->config(
     name => 'TestApp',\r
 );\r
 \r
-TestApp->setup( qw/Static::Simple/ );\r
+my @plugins = qw/-Debug Static::Simple/;\r
+\r
+# load the SubRequest plugin if available\r
+eval { require Catalyst::Plugin::SubRequest; };\r
+push @plugins, 'SubRequest' unless ($@);\r
+\r
+TestApp->setup( @plugins );\r
 \r
 sub incpath_generator {\r
     my $c = shift;\r
@@ -23,4 +29,16 @@ sub default : Private {
     $c->res->output( 'default' );\r
 }\r
 \r
+sub subtest : Local {\r
+    my ( $self, $c ) = @_;\r
+\r
+    $c->res->output( $c->subreq('/subtest2') );\r
+}\r
+\r
+sub subtest2 : Local {\r
+    my ( $self, $c ) = @_;\r
+    \r
+    $c->res->output( 'subtest2 ok' );\r
+}\r
+\r
 1;\r