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

(-)a/Koha/Object.pm (-1 / +1 lines)
Lines 605-611 sub to_api { Link Here
605
        }
605
        }
606
    }
606
    }
607
607
608
    $json_object->{_str} = $avs
608
    $json_object->{_strings} = $avs
609
      if $av_expand;
609
      if $av_expand;
610
610
611
    if ($embeds) {
611
    if ($embeds) {
(-)a/t/db_dependent/Koha/Object.t (-5 / +5 lines)
Lines 329-335 subtest "to_api() tests" => sub { Link Here
329
    is( ref($hold_api->{item}), 'HASH', 'Single nested object works correctly' );
329
    is( ref($hold_api->{item}), 'HASH', 'Single nested object works correctly' );
330
    is( $hold_api->{item}->{item_id}, $item->itemnumber, 'Object embedded correctly' );
330
    is( $hold_api->{item}->{item_id}, $item->itemnumber, 'Object embedded correctly' );
331
    is_deeply(
331
    is_deeply(
332
        $hold_api->{item}->{_str},
332
        $hold_api->{item}->{_strings},
333
        $_str,
333
        $_str,
334
        '_str correctly added to nested embed'
334
        '_str correctly added to nested embed'
335
    );
335
    );
Lines 511-521 subtest "to_api() tests" => sub { Link Here
511
        my $mobj = $marseille->to_api( { av_expand => 1, public => 1 } );
511
        my $mobj = $marseille->to_api( { av_expand => 1, public => 1 } );
512
        my $cobj = $cordoba->to_api( { av_expand => 1, public => 0 } );
512
        my $cobj = $cordoba->to_api( { av_expand => 1, public => 0 } );
513
513
514
        ok( exists $mobj->{_str}, '_str exists for Marseille' );
514
        ok( exists $mobj->{_strings}, '_str exists for Marseille' );
515
        ok( exists $cobj->{_str}, '_str exists for Córdoba' );
515
        ok( exists $cobj->{_strings}, '_str exists for Córdoba' );
516
516
517
        is_deeply(
517
        is_deeply(
518
            $mobj->{_str}->{country},
518
            $mobj->{_strings}->{country},
519
            {
519
            {
520
                category => $category->category_name,
520
                category => $category->category_name,
521
                str      => $france->lib_opac,
521
                str      => $france->lib_opac,
Lines 524-530 subtest "to_api() tests" => sub { Link Here
524
            'Authorised value for country expanded'
524
            'Authorised value for country expanded'
525
        );
525
        );
526
        is_deeply(
526
        is_deeply(
527
            $cobj->{_str}->{country},
527
            $cobj->{_strings}->{country},
528
            {
528
            {
529
                category => $category->category_name,
529
                category => $category->category_name,
530
                str      => $argentina->lib,
530
                str      => $argentina->lib,
(-)a/t/db_dependent/Koha/REST/Plugin/Objects.t (-20 / +19 lines)
Lines 716-736 subtest 'objects.find helper with expanded authorised values' => sub { Link Here
716
716
717
    $t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '+av_expand' } )
717
    $t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '+av_expand' } )
718
      ->status_is(200)->json_is( '/name' => 'Manuel' )
718
      ->status_is(200)->json_is( '/name' => 'Manuel' )
719
      ->json_has('/_str')
719
      ->json_has('/_strings')
720
      ->json_is( '/_str/country/type'     => 'av' )
720
      ->json_is( '/_strings/country/type'     => 'av' )
721
      ->json_is( '/_str/country/category' => $cat->category_name )
721
      ->json_is( '/_strings/country/category' => $cat->category_name )
722
      ->json_is( '/_str/country/str'      => $ar->lib );
722
      ->json_is( '/_strings/country/str'      => $ar->lib );
723
723
724
    $t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '' } )
724
    $t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '' } )
725
      ->status_is(200)->json_is( '/name' => 'Manuel' )
725
      ->status_is(200)->json_is( '/name' => 'Manuel' )
726
      ->json_hasnt('/_str');
726
      ->json_hasnt('/_strings');
727
727
728
    $t->get_ok( '/cities/' . $manuela->id => { 'x-koha-embed' => '+av_expand' } )
728
    $t->get_ok( '/cities/' . $manuela->id => { 'x-koha-embed' => '+av_expand' } )
729
      ->status_is(200)->json_is( '/name' => 'Manuela' )
729
      ->status_is(200)->json_is( '/name' => 'Manuela' )
730
      ->json_has('/_str')
730
      ->json_has('/_strings')
731
      ->json_is( '/_str/country/type'     => 'av' )
731
      ->json_is( '/_strings/country/type'     => 'av' )
732
      ->json_is( '/_str/country/category' => $cat->category_name )
732
      ->json_is( '/_strings/country/category' => $cat->category_name )
733
      ->json_is( '/_str/country/str'      => $us->lib );
733
      ->json_is( '/_strings/country/str'      => $us->lib );
734
734
735
    $schema->storage->txn_rollback;
735
    $schema->storage->txn_rollback;
736
};
736
};
Lines 832-851 subtest 'objects.search helper with expanded authorised values' => sub { Link Here
832
          { 'x-koha-embed' => '+av_expand' } )->status_is(200)
832
          { 'x-koha-embed' => '+av_expand' } )->status_is(200)
833
      ->json_has('/0')->json_has('/1')->json_hasnt('/2')
833
      ->json_has('/0')->json_has('/1')->json_hasnt('/2')
834
      ->json_is( '/0/name' => 'Manuel' )
834
      ->json_is( '/0/name' => 'Manuel' )
835
      ->json_has('/0/_str')
835
      ->json_has('/0/_strings')
836
      ->json_is( '/0/_str/country/str'      => $ar->lib )
836
      ->json_is( '/0/_strings/country/str'      => $ar->lib )
837
      ->json_is( '/0/_str/country/type'     => 'av' )
837
      ->json_is( '/0/_strings/country/type'     => 'av' )
838
      ->json_is( '/0/_str/country/category' => $cat->category_name )
838
      ->json_is( '/0/_strings/country/category' => $cat->category_name )
839
      ->json_is( '/1/name' => 'Manuela' )
839
      ->json_is( '/1/name' => 'Manuela' )
840
      ->json_has('/1/_str')
840
      ->json_has('/1/_strings')
841
      ->json_is( '/1/_str/country/str' => $us->lib )
841
      ->json_is( '/1/_strings/country/str' => $us->lib )
842
      ->json_is( '/1/_str/country/type'     => 'av' )
842
      ->json_is( '/1/_strings/country/type'     => 'av' )
843
      ->json_is( '/1/_str/country/category' => $cat->category_name );
843
      ->json_is( '/1/_strings/country/category' => $cat->category_name );
844
844
845
    $t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' )->status_is(200)
845
    $t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' )->status_is(200)
846
      ->json_has('/0')->json_has('/1')->json_hasnt('/2')
846
      ->json_has('/0')->json_has('/1')->json_hasnt('/2')
847
      ->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_str')
847
      ->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_strings')
848
      ->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_str');
848
      ->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_strings');
849
849
850
850
851
    $schema->storage->txn_rollback;
851
    $schema->storage->txn_rollback;
852
- 

Return to bug 26635