Add tests for forwarding to action object
Marcus Ramberg [Mon, 12 Jan 2009 15:14:38 +0000 (15:14 +0000)]
Changes
t/lib/TestApp/Controller/Action/Forward.pm
t/live_component_controller_action_forward.t

diff --git a/Changes b/Changes
index 5d78e99..d53ba61 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,10 +6,11 @@
         - Change streaming test to serve itself rather than 01use.t, making test
           sync for engines easier (t0m)
         - Workaround change in LWP that broke a cookie test (RT #40037)
-        - Back out go() since that feature's been pushed to 5.80
+        - Backport go() from 5.8 branch.
         - Fix some Win32 test failures
         - Add pt translation of error message (wreis)
         - Make :Chained('../action') work (Florian Ragwitz)
+        - Fix forwarding to action object.
         - Handle leading CRLF in HTTP requests sometimes sent by IE6 in keep-alive requests.
 
 5.7099_03 2008-07-20 10:10:00
index e118d73..d3ed612 100644 (file)
@@ -56,6 +56,12 @@ sub with_method_and_args : Local {
     $c->forward( qw/TestApp::Controller::Action::Forward args/, [qq/new/] );
     $c->res->body( $c->req->args->[0] );
 }
+sub to_action_object : Local {
+    my ( $self, $c ) = @_;
+    $c->forward($self->action_for('embed'), [qw/mtfnpy/]);
+}
+
 
 sub args : Local {
     my ( $self, $c, $val ) = @_;
index 7c14b78..2479fb6 100644 (file)
@@ -10,7 +10,7 @@ our $iters;
 
 BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
 
-use Test::More tests => 50 * $iters;
+use Test::More tests => 53 * $iters;
 use Catalyst::Test 'TestApp';
 
 if ( $ENV{CAT_BENCHMARK} ) {
@@ -245,4 +245,15 @@ sub run_tests {
         is( $response->content, '/action/forward/foo/bar',
              'forward_to_uri_check correct namespace');
     }
+    
+    # test forwarding to Catalyst::Action objects
+    {
+        ok( my $response = request(
+            'http://localhost/action/forward/to_action_object'),
+            'forward/to_action_object request');
+
+        ok( $response->is_success, 'forward/to_action_object successful');
+        is( $response->content, 'mtfnpy',
+             'forward/to_action_object forwards correctly');
+    }
 }