diff --git a/lib/MetaCPAN/Web/Controller/Author.pm b/lib/MetaCPAN/Web/Controller/Author.pm index 77a8c7b691..4a192ca639 100644 --- a/lib/MetaCPAN/Web/Controller/Author.pm +++ b/lib/MetaCPAN/Web/Controller/Author.pm @@ -94,6 +94,7 @@ sub releases : Chained('root') PathPart Args(0) { = $c->model('API::Release')->all_by_author( $id, $size, $page ); my ( $author, $releases ) = ( $author_cv->recv, $releases_cv->recv ); + $c->detach('/not_found') unless ( $author->{pauseid} ); my @releases = map { $_->{fields} } @{ $releases->{hits}->{hits} }; diff --git a/t/controller/author.t b/t/controller/author.t index 707c654f26..515b61d93c 100644 --- a/t/controller/author.t +++ b/t/controller/author.t @@ -10,6 +10,11 @@ test_psgi app, sub { is( $res->code, 404, 'code 404' ); ok( $res = $cb->( GET '/author/perler' ), 'GET /author/perler' ); is( $res->code, 301, 'code 301' ); + is( + $res->header('Location'), + 'http://localhost/author/PERLER', + '301 target' + ); ok( $res = $cb->( GET '/author/PERLER' ), 'GET /author/PERLER' ); is( $res->code, 200, 'code 200' ); my $tx = tx($res); @@ -19,6 +24,21 @@ test_psgi app, sub { ok( $res = $cb->( GET $release), "GET $release" ); is( $res->code, 200, 'code 200' ); + + ok( $res = $cb->( GET '/author/DOESNTEXIST/releases' ), + 'GET /author/DOESNTEXIST/releases' ); + is( $res->code, 404, 'code 404' ); + ok( $res = $cb->( GET '/author/perler/releases' ), + 'GET /author/perler/releases' ); + is( $res->code, 301, 'code 301' ); + is( + $res->header('Location'), + 'http://localhost/author/PERLER/releases', + '301 target' + ); + ok( $res = $cb->( GET '/author/PERLER/releases' ), + 'GET /author/PERLER/releases' ); + is( $res->code, 200, 'code 200' ); }; done_testing;