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

(-)a/Koha/REST/Plugin/Query.pm (-1 / +7 lines)
Lines 258-264 sub _parse_embed { Link Here
258
        $result->{$curr} = { children => _parse_embed( $next ) };
258
        $result->{$curr} = { children => _parse_embed( $next ) };
259
    }
259
    }
260
    else {
260
    else {
261
        $result->{$curr} = {};
261
        if ( $curr =~ m/^(?<relation>.*)\+count/ ) {
262
            my $key = $+{relation} . "_count";
263
            $result->{$key} = { is_count => 1 };
264
        }
265
        else {
266
            $result->{$curr} = {};
267
        }
262
    }
268
    }
263
269
264
    return $result;
270
    return $result;
(-)a/t/Koha/REST/Plugin/Query.t (-3 / +7 lines)
Lines 150-156 get '/stash_embed' => sub { Link Here
150
                    'x-koha-embed' => [
150
                    'x-koha-embed' => [
151
                        'checkouts',
151
                        'checkouts',
152
                        'checkouts.item',
152
                        'checkouts.item',
153
                        'library'
153
                        'library',
154
                        'holds+count'
154
                    ]
155
                    ]
155
                }
156
                }
156
            }
157
            }
Lines 309-315 subtest '_build_query_params_from_api' => sub { Link Here
309
310
310
subtest 'stash_embed() tests' => sub {
311
subtest 'stash_embed() tests' => sub {
311
312
312
    plan tests => 12;
313
    plan tests => 15;
313
314
314
    my $t = Test::Mojo->new;
315
    my $t = Test::Mojo->new;
315
316
Lines 321-326 subtest 'stash_embed() tests' => sub { Link Here
321
      ->status_is(200)
322
      ->status_is(200)
322
      ->json_is( { checkouts => { children => { item => {} } }, library => {} } );
323
      ->json_is( { checkouts => { children => { item => {} } }, library => {} } );
323
324
325
    $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'holds+count' } )
326
      ->status_is(200)
327
      ->json_is( { holds_count => { is_count => 1 } } );
328
324
    $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } )
329
    $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } )
325
      ->status_is(400)
330
      ->status_is(400)
326
      ->json_is(
331
      ->json_is(
327
- 

Return to bug 24528