Skip to content

Commit

Permalink
fix showing pod when in separate file from pm
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Jan 31, 2024
1 parent fadb16c commit 909c535
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/MetaCPAN/Web/Model/API/Pod.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ sub file_pod {

$opts ||= {};

my $pod_path
= '/pod/'
. ( $file->{assoc_pod}
|| "$file->{author}/$file->{release}/$file->{path}" );
my $pod_path = join '/',
$file->{author},
$file->{release},
$file->{pod_path} || $file->{path};

return $self->request(
$pod_path,
"/pod/$pod_path",
undef,
{
show_errors => 1,
Expand Down
20 changes: 20 additions & 0 deletions t/controller/pod.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ test_psgi app, sub {
is( $res->code, 301, '301 on lowercase author name' );
my $location = $res->headers->header('location') =~ s{^http://[^/]+}{}r;
is( $location, $this, 'redirect to uppercase author name' );

subtest 'split pod' => sub {
my $res
= $cb->(
GET '/release/KHW/Pod-Simple-3.45/view/lib/Pod/Simple.pm' );
is( $res->code, 200, 'found older Pod::Simple pod' );

my $tx = tx($res);
$tx->like(
'//h1[@id="NAME"]/following-sibling::p//text()',
qr/framework for parsing Pod/,
'contains pod content'
);
$tx->is(
'//a[text()="Pod Source"]/@href',
'/release/KHW/Pod-Simple-3.45/source/lib/Pod/Simple.pod',
'contains link to pod'
);
};

};

done_testing;

0 comments on commit 909c535

Please sign in to comment.