Skip to content

Commit

Permalink
Test /dist/$dist/$version/$path.html.
Browse files Browse the repository at this point in the history
Make sure it properly handles 404s. In passing, tweak the distribution
template to properly highlight the distribution link, and tweak the document
template to make the distribution link URL a path rather than a full URL.
Also, change the arrow separator in the breadcrumb to something a little less
huge.
  • Loading branch information
theory committed Mar 30, 2011
1 parent faeea8b commit 448ba95
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/PGXN/Site/Templates.pm
Expand Up @@ -566,9 +566,9 @@ template distribution => sub {
$dist->user;
} };
li {
class is 'sub';
class is 'sub here';
a {
href is $req->uri;
href is $req->uri->path;
title is $args->{dist_name};
$args->{dist_name};
}
Expand Down Expand Up @@ -611,8 +611,9 @@ template document => sub {
};
li {
class is 'sub here';
$title;
a {
href is $req->uri;
href is $req->uri->path;
title is $title;
$title;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/PGXN/Site/ui/css/layout.css
Expand Up @@ -163,7 +163,7 @@
}

#crumb li.sub:before {
content:"";
content:"";
}

#loading {
Expand Down
40 changes: 39 additions & 1 deletion t/router.t
Expand Up @@ -128,7 +128,7 @@ test_psgi $app => sub {
'The body should have the invalid in param error';
};

# Test /dist/
# Test /dist/$dist and /dist/$dist/$version
test_psgi $app => sub {
my $cb = shift;

Expand All @@ -143,8 +143,46 @@ test_psgi $app => sub {
my $title = $uri =~ /0/ ? 'pair 0.1.1' : 'pair';
like $res->content, qr{<h1>\Q$title</h1>},
"The body should have the h1 $title";
}

};

# Test /dist/$dist/$path and /dist/$dist/$version/$path/
test_psgi $app => sub {
my $cb = shift;

my $uri = '/dist/pair/doc/pair.html';
ok my $res = $cb->(GET $uri), "Fetch $uri";
ok $res->is_success, 'Should be a success';
like $res->content, qr{<a href="/dist/pair/" title="pair">pair</a>},
"The body should have the distribution link";
like $res->content, qr{<a href="/dist/pair/doc/pair\.html" title="pair">pair</a>},
"The body should have the doc link";

$uri = '/dist/pair/0.1.1/doc/pair.html';
ok $res = $cb->(GET $uri), "Fetch $uri";
ok $res->is_success, 'Should be a success';
like $res->content, qr{\Q<a href="/dist/pair/0.1.1/" title="pair 0.1.1">pair 0.1.1</a>},
"The body should have the distribution link";
like $res->content, qr{\Q<a href="/dist/pair/0.1.1/doc/pair.html" title="pair">pair</a>},
"The body should have the doc link";

# Make sure we get 404 for nonexistent doc.
for my $version ('', '/0.1.1') {
my $uri = "/dist/pair$version/doc/nonexistent.html";
ok my $res = $cb->(GET $uri), "Fetch $uri";
ok !$res->is_success, 'Should not be a success';
is $res->code, 404, 'Should get 404 response';
like $res->content, qr/Resource not found\./,
'The body should have the error';
}

# Make sure we get 404 for nonexistent dist.
$uri = '/dist/nonesuch/doc/nonesuch.html';
ok $res = $cb->(GET $uri), "Fetch $uri";
ok !$res->is_success, 'Should not be a success';
is $res->code, 404, 'Should get 404 response';
like $res->content, qr/Resource not found\./,
'The body should have the error';
};

0 comments on commit 448ba95

Please sign in to comment.