From: Ash Berlin Date: Sun, 1 Mar 2009 17:15:46 +0000 (+0000) Subject: TWMC: Fix bug where redirect was followed on a 500 response X-Git-Tag: 0.51~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FTest-WWW-Mechanize-Catalyst.git;a=commitdiff_plain;h=affa35d5063fbeb1ca9ccc5bff2372b583c8575f TWMC: Fix bug where redirect was followed on a 500 response --- diff --git a/CHANGES b/CHANGES index b65c670..dde5d7c 100644 --- 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 diff --git a/lib/Test/WWW/Mechanize/Catalyst.pm b/lib/Test/WWW/Mechanize/Catalyst.pm index ccc6890..8910c44 100644 --- a/lib/Test/WWW/Mechanize/Catalyst.pm +++ b/lib/Test/WWW/Mechanize/Catalyst.pm @@ -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 ) ) { diff --git a/svn.authors b/svn.authors index c6b7137..abc53b2 100644 --- a/svn.authors +++ b/svn.authors @@ -1 +1 @@ -ashb = Ash Berlin +ash = Ash Berlin diff --git a/t/lib/Catty.pm b/t/lib/Catty.pm index c67429a..83e6745 100644 --- a/t/lib/Catty.pm +++ b/t/lib/Catty.pm @@ -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" ); diff --git a/t/redirect.t b/t/redirect.t index d7e25d4..8b08bc1 100644 --- a/t/redirect.t +++ b/t/redirect.t @@ -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");