Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend 404 messages with a "Not found: " string, fill in an error (or t... #181

Merged
merged 1 commit into from Apr 1, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Server/Controller/Root.pm
Expand Up @@ -12,7 +12,7 @@ sub default : Path {
sub not_found : Private {
my ( $self, $c, $message ) = @_;
$c->clear_stash;
$c->stash( { message => $message || 'Not found' } );
$c->stash( { message => "Not found: " . ($message || "No error...") } );
$c->response->status(404);
$c->forward($c->view('JSON'));
}
Expand Down
6 changes: 4 additions & 2 deletions t/server/controller/pod.t
Expand Up @@ -11,7 +11,7 @@ $fh->close;
my %tests = (

# TODO
#'/pod' => 404,
#'/pod' => 404,
'/pod/DOESNEXIST' => 404,
'/pod/Moose' => 200,
'/pod/DOY/Moose-0.01/lib/Moose.pm' => 200,
Expand All @@ -32,14 +32,16 @@ test_psgi app, sub {
);
if($k eq '/pod/Pod::Pm') {
like( $res->content, qr/Pod::Pm - abstract/, 'NAME section' );
} elsif ( $v eq 200 ) {
} elsif ( $v == 200 ) {
like( $res->content, qr/Moose - abstract/, 'NAME section' );
ok( $res = $cb->( GET "$k?content-type=text/plain" ),
"GET plain" );
is( $res->header('content-type'),
'text/plain; charset=UTF-8',
'Content-type'
);
} elsif ( $v == 404 ) {
like( $res->content, qr/Not found: (\w+)/, "404 correct error");
}

my $ct = $k =~ /Moose[.]pm$/ ? '&content-type=text/x-pod' : '';
Expand Down