View | Details | Raw Unified | Return to bug 24528
Collapse All | Expand All

(-)a/Koha/REST/Plugin/Query.pm (-1 / +7 lines)
Lines 263-269 sub _parse_embed { Link Here
263
        $result->{$curr} = { children => _parse_embed( $next ) };
263
        $result->{$curr} = { children => _parse_embed( $next ) };
264
    }
264
    }
265
    else {
265
    else {
266
        $result->{$curr} = {};
266
        if ( $curr =~ m/^(?<relation>.*)\+count/ ) {
267
            my $key = $+{relation} . "_count";
268
            $result->{$key} = { is_count => 1 };
269
        }
270
        else {
271
            $result->{$curr} = {};
272
        }
267
    }
273
    }
268
274
269
    return $result;
275
    return $result;
(-)a/t/Koha/REST/Plugin/Query.t (-3 / +7 lines)
Lines 140-146 get '/stash_embed' => sub { Link Here
140
                    'x-koha-embed' => [
140
                    'x-koha-embed' => [
141
                        'checkouts',
141
                        'checkouts',
142
                        'checkouts.item',
142
                        'checkouts.item',
143
                        'library'
143
                        'library',
144
                        'holds+count'
144
                    ]
145
                    ]
145
                }
146
                }
146
            }
147
            }
Lines 304-310 subtest '_build_query_params_from_api' => sub { Link Here
304
305
305
subtest 'stash_embed() tests' => sub {
306
subtest 'stash_embed() tests' => sub {
306
307
307
    plan tests => 12;
308
    plan tests => 15;
308
309
309
    my $t = Test::Mojo->new;
310
    my $t = Test::Mojo->new;
310
311
Lines 316-321 subtest 'stash_embed() tests' => sub { Link Here
316
      ->status_is(200)
317
      ->status_is(200)
317
      ->json_is( { checkouts => { children => { item => {} } }, library => {} } );
318
      ->json_is( { checkouts => { children => { item => {} } }, library => {} } );
318
319
320
    $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'holds+count' } )
321
      ->status_is(200)
322
      ->json_is( { holds_count => { is_count => 1 } } );
323
319
    $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } )
324
    $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } )
320
      ->status_is(400)
325
      ->status_is(400)
321
      ->json_is(
326
      ->json_is(
322
- 

Return to bug 24528