Skip to content

Commit

Permalink
Merge pull request #1582 from CPAN-API/uri-escape-issue-url
Browse files Browse the repository at this point in the history
URI escape fabricated RT urls
  • Loading branch information
oalders committed Aug 23, 2015
2 parents bf705cd + a31259b commit 3dfd724
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions cpanfile
Expand Up @@ -86,6 +86,7 @@ requires 'Text::Pluralize';
requires 'Try::Tiny', '0.09';
requires 'YAML', '1.15'; # fix dep chain issue
requires 'URI';
requires 'URI::Escape';
requires 'XML::Feed';
requires 'XML::Simple';

Expand Down
3 changes: 2 additions & 1 deletion lib/MetaCPAN/Web/Model/ReleaseInfo.pm
Expand Up @@ -187,7 +187,8 @@ sub normalize_issues {
$issues->{url} = 'mailto:' . $bugtracker->{mailto};
}
else {
$issues->{url} = $self->rt_url_prefix . $release->{distribution};
$issues->{url}
= $self->rt_url_prefix . uri_escape( $release->{distribution} );
}

if ( my $bugs = $distribution->{bugs} ) {
Expand Down
19 changes: 15 additions & 4 deletions t/controller/shared/release-info.t
Expand Up @@ -3,6 +3,11 @@ use warnings;
use Test::More 0.96;
use MetaCPAN::Web::Test;

use Module::Runtime qw( use_module );

my $model = use_module('MetaCPAN::Web::Model::ReleaseInfo');
my $rt_prefix = $model->rt_url_prefix;

# Test various aspects that should be similar
# among controllers that show release info (in the side bar).
# Currently this includes module and release controllers.
Expand All @@ -13,6 +18,7 @@ my @optional = qw(
home_page
repository
reviews
issues
);

# Use a counter to make sure we at least do each optional test once.
Expand All @@ -32,7 +38,10 @@ test_psgi app, sub {
my @tests = (

# has all optional tests
{ module => 'Dist::Zilla' },
{
module => 'Dist::Zilla',
issues => 'https://github.com/rjbs/Dist-Zilla/issues'
},

# dist name that needs uri encoding
{
Expand Down Expand Up @@ -69,6 +78,7 @@ test_psgi app, sub {
my $qs_module = $test->{module};

# turn tests on by default
$test->{issues} //= $rt_prefix . $qs_dist;
exists( $test->{$_} ) or $test->{$_} = 1 for @optional;

# short cuts
Expand Down Expand Up @@ -156,9 +166,10 @@ test_psgi app, sub {
'link for resources.repository.url' );
};

# we could test the rt.cpan.org link... i think others are verbatim from the META file
ok( $tx->find_value('//a[text()="Issues"]/@href'),
'link for bug tracker' );
optional_test issues => sub {
$tx->is( '//a[text()="Issues"]/@href', $test->{issues},
'link to bug tracker' );
};

# not all dists have reviews
optional_test reviews => sub {
Expand Down

0 comments on commit 3dfd724

Please sign in to comment.