diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml index 138e9e8e7e..3621453c70 100644 --- a/api/v1/swagger/paths/patrons.yaml +++ b/api/v1/swagger/paths/patrons.yaml @@ -507,6 +507,7 @@ enum: - +strings - extended_attributes + - library collectionFormat: csv produces: - application/json diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t index 5042f564a4..ec59b41b52 100755 --- a/t/db_dependent/api/v1/patrons.t +++ b/t/db_dependent/api/v1/patrons.t @@ -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 {