TWMC: Fix bug where redirect was followed on a 500 response
Ash Berlin [Sun, 1 Mar 2009 17:15:46 +0000 (17:15 +0000)]
CHANGES
lib/Test/WWW/Mechanize/Catalyst.pm
svn.authors
t/lib/Catty.pm
t/redirect.t

diff --git a/CHANGES b/CHANGES
index b65c670..dde5d7c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,7 @@ Revision history for Perl module Test::WWW::Mechanize::Catalyst:
 
      - Doc updates from Jester
      - User agent fixes from ANDREMAR
+     - Fix bug where redirect was followed on a 500 response
 
 0.50 Tue Feb 17 09:12 GMT 2009
      - Remove warning in HTTP::Cookies
index ccc6890..8910c44 100644 (file)
@@ -99,6 +99,7 @@ sub _make_request {
 
     # check if that was a redirect
     if (   $response->header('Location')
+        && $response->is_redirect
         && $self->redirect_ok( $request, $response ) )
     {
 
index c6b7137..abc53b2 100644 (file)
@@ -1 +1 @@
-ashb = Ash Berlin <ash_github@firemirror.com>
+ash = Ash Berlin <ash_github@firemirror.com>
index c67429a..83e6745 100644 (file)
@@ -1,6 +1,7 @@
 package Catty;
 
 use strict;
+use warnings;
 
 #use Catalyst;
 use Catalyst;
@@ -76,6 +77,13 @@ sub check_auth_basic : Global {
     }
 }
 
+sub redirect_with_500 : Global {
+    my ( $self, $c ) = @_;
+    $DB::single = 1;
+    $c->res->redirect( $c->uri_for("/bonjour"));
+    die "erk!";
+}
+
 sub die : Global {
     my ( $self, $context ) = @_;
     my $html = html( "Die", "This is the die page" );
index d7e25d4..8b08bc1 100644 (file)
@@ -1,8 +1,8 @@
-#!perl -T
+#!perl
 use strict;
 use warnings;
 use lib 'lib';
-use Test::More tests => 27;
+use Test::More tests => 28;
 use lib 't/lib';
 use Test::WWW::Mechanize::Catalyst 'Catty';
 
@@ -30,3 +30,6 @@ my $prev = $m->response->previous->previous;
 ok( $prev, "have a previous previous" );
 is( $prev->code, 302, "was a redirect" );
 like( $prev->header('Location'), '/hi$/', "to the right place" );
+
+$m->get("$root/redirect_with_500");
+is ($m->status, 500, "Redirect not followed on 500");