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

(-)a/Koha/Illrequest.pm (-2 / +2 lines)
Lines 1018-1025 sub TO_JSON { Link Here
1018
            $object->{capabilities} = $self->capabilities;
1018
            $object->{capabilities} = $self->capabilities;
1019
        }
1019
        }
1020
        # Augment the request response with library details if appropriate
1020
        # Augment the request response with library details if appropriate
1021
        if ( $embed->{branch} ) {
1021
        if ( $embed->{library} ) {
1022
            $object->{branch} = Koha::Libraries->find(
1022
            $object->{library} = Koha::Libraries->find(
1023
                $self->branchcode
1023
                $self->branchcode
1024
            )->TO_JSON;
1024
            )->TO_JSON;
1025
        }
1025
        }
(-)a/api/v1/swagger/paths/illrequests.json (-1 / +1 lines)
Lines 15-21 Link Here
15
                    "type": "string",
15
                    "type": "string",
16
                    "enum": [
16
                    "enum": [
17
                        "patron",
17
                        "patron",
18
                        "branch",
18
                        "library",
19
                        "capabilities",
19
                        "capabilities",
20
                        "metadata"
20
                        "metadata"
21
                    ]
21
                    ]
(-)a/t/db_dependent/Illrequests.t (-5 / +5 lines)
Lines 837-847 subtest 'TO_JSON() tests' => sub { Link Here
837
        undef, '%embed not passed, no \'metadata\' attribute' );
837
        undef, '%embed not passed, no \'metadata\' attribute' );
838
    is( $illreq_json->{capabilities},
838
    is( $illreq_json->{capabilities},
839
        undef, '%embed not passed, no \'capabilities\' attribute' );
839
        undef, '%embed not passed, no \'capabilities\' attribute' );
840
    is( $illreq_json->{branch},
840
    is( $illreq_json->{library},
841
        undef, '%embed not passed, no \'branch\' attribute' );
841
        undef, '%embed not passed, no \'library\' attribute' );
842
842
843
    $illreq_json = $illreq->TO_JSON(
843
    $illreq_json = $illreq->TO_JSON(
844
        { patron => 1, metadata => 1, capabilities => 1, branch => 1 } );
844
        { patron => 1, metadata => 1, capabilities => 1, library => 1 } );
845
    is( $illreq_json->{patron}->{firstname},
845
    is( $illreq_json->{patron}->{firstname},
846
        $patron->firstname,
846
        $patron->firstname,
847
        '%embed passed, \'patron\' attribute correct (firstname)' );
847
        '%embed passed, \'patron\' attribute correct (firstname)' );
Lines 855-862 subtest 'TO_JSON() tests' => sub { Link Here
855
        'metawhat?', '%embed passed, \'metadata\' attribute correct' );
855
        'metawhat?', '%embed passed, \'metadata\' attribute correct' );
856
    is( $illreq_json->{capabilities},
856
    is( $illreq_json->{capabilities},
857
        'capable', '%embed passed, \'capabilities\' attribute correct' );
857
        'capable', '%embed passed, \'capabilities\' attribute correct' );
858
    is( $illreq_json->{branch}->{branchcode},
858
    is( $illreq_json->{library}->{branchcode},
859
        $library->branchcode, '%embed not passed, no \'branch\' attribute' );
859
        $library->branchcode, '%embed not passed, no \'library\' attribute' );
860
860
861
    $schema->storage->txn_rollback;
861
    $schema->storage->txn_rollback;
862
};
862
};
(-)a/t/db_dependent/api/v1/illrequests.t (-3 / +2 lines)
Lines 81-93 subtest 'list() tests' => sub { Link Here
81
81
82
    # One illrequest created, returned with augmented data
82
    # One illrequest created, returned with augmented data
83
    $tx = $t->ua->build_tx( GET =>
83
    $tx = $t->ua->build_tx( GET =>
84
          '/api/v1/illrequests?embed=patron,branch,capabilities,metadata' );
84
          '/api/v1/illrequests?embed=patron,library,capabilities,metadata' );
85
    $tx->req->cookies( { name => 'CGISESSID', value => $session_id } );
85
    $tx->req->cookies( { name => 'CGISESSID', value => $session_id } );
86
    $tx->req->env( { REMOTE_ADDR => $remote_address } );
86
    $tx->req->env( { REMOTE_ADDR => $remote_address } );
87
    $t->request_ok($tx)->status_is(200)->json_is(
87
    $t->request_ok($tx)->status_is(200)->json_is(
88
        [
88
        [
89
            $illrequest->TO_JSON(
89
            $illrequest->TO_JSON(
90
                { patron => 1, branch => 1, capabilities => 1, metadata => 1 }
90
                { patron => 1, library => 1, capabilities => 1, metadata => 1 }
91
            )
91
            )
92
        ]
92
        ]
93
    );
93
    );
94
- 

Return to bug 7317