Skip to content

Commit b528e58

Browse files
committed
fix parsing of rating end points
The fake rating search end points need the Deserialize ActionClass to parse their body. Also, MetaCPAN::Client has a bug that prevents it from properly using its testing user agent, so just give the results for normal MC::C UAs.
1 parent 37fe00c commit b528e58

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/MetaCPAN/Server/Controller/Rating.pm

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ sub _mapping : Path('_mapping') : Args(0) {
2828
$c->detach('/not_found');
2929
}
3030

31-
sub find : Path('_search') : Args(0) {
31+
sub find : Path('_search') : Args(0) : ActionClass('~Deserialize') {
3232
my ( $self, $c, $scroll ) = @_;
3333

3434
my @hits;
3535

3636
# fake results for MetaCPAN::Client so it doesn't fail its tests
37-
if ( ( $c->req->user_agent // '' )
38-
=~ m{^MetaCPAN::Client-testing/([0-9.]+)} )
39-
{
37+
if ( ( $c->req->user_agent // '' ) =~ m{^MetaCPAN::Client/([0-9.]+)} ) {
4038
if ( $1 <= 2.031001 ) {
41-
my $query = $c->read_param('query');
39+
my $query = $c->params->{'query'};
4240
if ( $query
4341
&& $query->[0]
4442
&& $query->[0]{term}
@@ -72,7 +70,7 @@ sub find : Path('_search') : Args(0) {
7270
} );
7371
}
7472

75-
sub all : Path('') : Args(0) {
73+
sub all : Path('') : Args(0) : ActionClass('~Deserialize') {
7674
my ( $self, $c ) = @_;
7775
$c->forward('find');
7876
}

t/server/controller/rating.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ test_psgi app, sub {
9292
ok(
9393
$res = $cb->(
9494
POST '/rating/_search',
95-
'User-Agent' => 'MetaCPAN::Client-testing/2.031001',
95+
'User-Agent' => 'MetaCPAN::Client/2.031001',
9696
Content => '{"query":{"term":{"distribution":"Moose"}}}',
9797
),
9898
'POST /rating with MetaCPAN::Client test UA'

0 commit comments

Comments
 (0)