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

(-)a/t/Koha/REST/Plugin/Query.t (-2 / +92 lines)
Lines 285-290 get '/stash_overrides' => sub { Link Here
285
    );
285
    );
286
};
286
};
287
287
288
get '/dbic_extended_attributes_join' => sub {
289
    my ( $c, $args ) = @_;
290
291
    my $filtered_params = [
292
        {
293
            '-and' => [
294
                [
295
                    {
296
                        'extended_attributes.attribute' => { 'like' => 'abc%' },
297
                        'extended_attributes.code'      => [
298
                            [
299
                                'test1',
300
                                'test2'
301
                            ]
302
                        ]
303
                    }
304
                ],
305
                [
306
                    {
307
                        'extended_attributes.code' => [
308
                            [
309
                                'test1',
310
                                'test2'
311
                            ]
312
                        ],
313
                        'extended_attributes.attribute' => { 'like' => '123%' }
314
                    }
315
                ]
316
            ]
317
        }
318
    ];
319
    my $attributes = { 'prefetch' => ['extended_attributes'] };
320
321
    $c->dbic_extended_attributes_join(
322
        {
323
            'filtered_params' => $filtered_params,
324
            'attributes'      => $attributes
325
        }
326
    );
327
328
    $c->render( json => { 'attributes' => $attributes, 'filtered_params' => $filtered_params }, status => 200 );
329
};
330
288
sub to_model {
331
sub to_model {
289
    my ($args) = @_;
332
    my ($args) = @_;
290
    $args->{three} = delete $args->{tres}
333
    $args->{three} = delete $args->{tres}
Lines 294-300 sub to_model { Link Here
294
337
295
# The tests
338
# The tests
296
339
297
use Test::More tests => 7;
340
use Test::More tests => 8;
298
use Test::Mojo;
341
use Test::Mojo;
299
342
300
subtest 'extract_reserved_params() tests' => sub {
343
subtest 'extract_reserved_params() tests' => sub {
Lines 543-545 subtest 'stash_overrides() tests' => sub { Link Here
543
      ->json_is( {} ); # x-koha-ovverride not passed is skipped
586
      ->json_is( {} ); # x-koha-ovverride not passed is skipped
544
587
545
};
588
};
546
- 
589
590
subtest 'dbic_extended_attributes_join() tests' => sub {
591
592
    plan tests => 4;
593
594
    my $t = Test::Mojo->new;
595
596
    $t->get_ok( '/dbic_extended_attributes_join' => { 'x-koha-embed' => 'extended_attributes' } )->json_has(
597
        '/attributes' => {
598
            'join' => [
599
                'extended_attributes',
600
                'extended_attributes'
601
            ],
602
            'prefetch' => ['extended_attributes']
603
        }
604
    );
605
606
    $t->get_ok( '/dbic_extended_attributes_join' => { 'x-koha-embed' => 'extended_attributes' } )->json_has(
607
        '/filtered_params' => [
608
            {
609
                '-and' => [
610
                    [
611
                        {
612
                            'extended_attributes.code' => [
613
                                [
614
                                    'test1',
615
                                    'test2'
616
                                ]
617
                            ],
618
                            'extended_attributes.attribute' => { 'like' => 'abc%' }
619
                        }
620
                    ],
621
                    [
622
                        {
623
                            'extended_attributes_2.attribute' => { 'like' => '123%' },
624
                            'extended_attributes_2.code'      => [
625
                                [
626
                                    'test1',
627
                                    'test2'
628
                                ]
629
                            ]
630
                        }
631
                    ]
632
                ]
633
            }
634
        ]
635
    );
636
};

Return to bug 30645