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

(-)a/t/db_dependent/api/v1/patrons.t (-13 / +31 lines)
Lines 81-87 subtest 'list() tests' => sub { Link Here
81
81
82
    subtest 'librarian access tests' => sub {
82
    subtest 'librarian access tests' => sub {
83
83
84
        plan tests => 21;
84
        plan tests => 15;
85
85
86
        $schema->storage->txn_begin;
86
        $schema->storage->txn_begin;
87
87
Lines 137-155 subtest 'list() tests' => sub { Link Here
137
          ->status_is(200)
137
          ->status_is(200)
138
          ->json_is('/0/address2' => $librarian->address2);
138
          ->json_is('/0/address2' => $librarian->address2);
139
139
140
        my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
140
        subtest 'restricted & expired' => sub {
141
        AddDebarment( { borrowernumber => $patron->borrowernumber } );
142
141
143
        $t->get_ok("//$userid:$password@/api/v1/patrons?restricted=" . Mojo::JSON->true . "&cardnumber=" . $patron->cardnumber )
142
            plan tests => 13;
144
          ->status_is(200)
143
145
          ->json_has('/0/restricted')
144
            my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
146
          ->json_is( '/0/restricted' => Mojo::JSON->true )
145
147
          ->json_hasnt('/1');
146
            AddDebarment( { borrowernumber => $patron->borrowernumber } );
148
147
149
        $t->get_ok( "//$userid:$password@/api/v1/patrons?"
148
            $t->get_ok("//$userid:$password@/api/v1/patrons?restricted=" . Mojo::JSON->true . "&cardnumber=" . $patron->cardnumber )
150
              . 'q={"extended_attributes.type":"CODE"}' =>
149
              ->status_is(200)
151
              { 'x-koha-embed' => 'extended_attributes' } )
150
              ->json_has('/0/restricted')
152
          ->status_is( 200, "Works, doesn't explode" );
151
              ->json_is( '/0/restricted' => Mojo::JSON->true )
152
              ->json_has('/0/expired')
153
              ->json_is( '/0/expired' => Mojo::JSON->false )
154
              ->json_hasnt('/1');
155
156
            $patron->dateexpiry(dt_from_string->subtract(days => 2))->store;
157
            $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->borrowernumber)
158
              ->status_is(200)
159
              ->json_has('/expired')
160
              ->json_is( '/expired' => Mojo::JSON->true );
161
162
            $t->get_ok( "//$userid:$password@/api/v1/patrons?"
163
                  . 'q={"extended_attributes.type":"CODE"}' =>
164
                  { 'x-koha-embed' => 'extended_attributes' } )
165
              ->status_is( 200, "Works, doesn't explode" );
166
        };
153
167
154
        subtest 'searching date and date-time fields' => sub {
168
        subtest 'searching date and date-time fields' => sub {
155
169
Lines 443-448 subtest 'add() tests' => sub { Link Here
443
        # delete RO attributes
457
        # delete RO attributes
444
        delete $newpatron->{patron_id};
458
        delete $newpatron->{patron_id};
445
        delete $newpatron->{restricted};
459
        delete $newpatron->{restricted};
460
        delete $newpatron->{expired};
446
        delete $newpatron->{anonymized};
461
        delete $newpatron->{anonymized};
447
462
448
        # Create a library just to make sure its ID doesn't exist on the DB
463
        # Create a library just to make sure its ID doesn't exist on the DB
Lines 488-493 subtest 'add() tests' => sub { Link Here
488
        # delete RO attributes
503
        # delete RO attributes
489
        delete $newpatron->{patron_id};
504
        delete $newpatron->{patron_id};
490
        delete $newpatron->{restricted};
505
        delete $newpatron->{restricted};
506
        delete $newpatron->{expired};
491
        delete $newpatron->{anonymized};
507
        delete $newpatron->{anonymized};
492
        $patron_to_delete->delete;
508
        $patron_to_delete->delete;
493
509
Lines 739-744 subtest 'update() tests' => sub { Link Here
739
        # delete RO attributes
755
        # delete RO attributes
740
        delete $newpatron->{patron_id};
756
        delete $newpatron->{patron_id};
741
        delete $newpatron->{restricted};
757
        delete $newpatron->{restricted};
758
        delete $newpatron->{expired};
742
        delete $newpatron->{anonymized};
759
        delete $newpatron->{anonymized};
743
760
744
        $t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron)
761
        $t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron)
Lines 814-819 subtest 'update() tests' => sub { Link Here
814
        # Put back the RO attributes
831
        # Put back the RO attributes
815
        $newpatron->{patron_id} = $unauthorized_patron->to_api({ user => $authorized_patron })->{patron_id};
832
        $newpatron->{patron_id} = $unauthorized_patron->to_api({ user => $authorized_patron })->{patron_id};
816
        $newpatron->{restricted} = $unauthorized_patron->to_api({ user => $authorized_patron })->{restricted};
833
        $newpatron->{restricted} = $unauthorized_patron->to_api({ user => $authorized_patron })->{restricted};
834
        $newpatron->{expired} = $unauthorized_patron->to_api({ user => $authorized_patron })->{expired};
817
        $newpatron->{anonymized} = $unauthorized_patron->to_api({ user => $authorized_patron })->{anonymized};
835
        $newpatron->{anonymized} = $unauthorized_patron->to_api({ user => $authorized_patron })->{anonymized};
818
836
819
        my $got = $result->tx->res->json;
837
        my $got = $result->tx->res->json;
Lines 845-850 subtest 'update() tests' => sub { Link Here
845
        # delete RO attributes
863
        # delete RO attributes
846
        delete $newpatron->{patron_id};
864
        delete $newpatron->{patron_id};
847
        delete $newpatron->{restricted};
865
        delete $newpatron->{restricted};
866
        delete $newpatron->{expired};
848
        delete $newpatron->{anonymized};
867
        delete $newpatron->{anonymized};
849
868
850
        # attempt to update
869
        # attempt to update
851
- 

Return to bug 36454