Bug 42207: Allow library embed on GET /patrons/{patron_id}
- Add 'library' to the allowed x-koha-embed values for the
GET /patrons/{patron_id} endpoint
- Add unit test verifying the library embed returns library_id
and name
Test plan:
1. Apply patch
2. yarn api:bundle
3. prove t/db_dependent/api/v1/patrons.t
4. Verify all tests pass, including the new 'library embed'
subtest under get() which verifies that requesting
x-koha-embed: library returns the patron's library object
Sponsored-by: Büchereizentrale Schleswig-Holstein <https://www.bz-sh.de/>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
ad30c815ce
commit
138d2b64ed
|
|
@ -507,6 +507,7 @@
|
|||
enum:
|
||||
- +strings
|
||||
- extended_attributes
|
||||
- library
|
||||
collectionFormat: csv
|
||||
produces:
|
||||
- application/json
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ subtest 'list() tests' => sub {
|
|||
|
||||
subtest 'get() tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 5;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
unauthorized_access_tests( 'GET', -1, undef );
|
||||
|
|
@ -431,6 +431,32 @@ subtest 'get() tests' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'library embed' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
|
||||
my $librarian = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => { flags => 2**4 } # borrowers flag = 4
|
||||
}
|
||||
);
|
||||
my $password = 'thePassword123';
|
||||
$librarian->set_password( { password => $password, skip_validation => 1 } );
|
||||
my $userid = $librarian->userid;
|
||||
|
||||
$t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id => { "x-koha-embed" => "library" } )
|
||||
->status_is(200)
|
||||
->json_is( '/library/library_id' => $patron->branchcode )
|
||||
->json_is( '/library/name' => $patron->library->branchname );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
};
|
||||
|
||||
subtest 'add() tests' => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue