From 8d553e0a8bcc0e81db156b8ccfe90341b7d995ae Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 1 Nov 2024 12:54:09 +0000 Subject: [PATCH] Bug 38322: Adust tests --- t/db_dependent/api/v1/erm_users.t | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/erm_users.t b/t/db_dependent/api/v1/erm_users.t index f0381053847..ad60b1b2aae 100755 --- a/t/db_dependent/api/v1/erm_users.t +++ b/t/db_dependent/api/v1/erm_users.t @@ -35,7 +35,7 @@ t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); subtest 'list() tests' => sub { - plan tests => 11; + plan tests => 14; $schema->storage->txn_begin; @@ -70,10 +70,21 @@ subtest 'list() tests' => sub { } ); - # Two erm_users created, they should both be returned + # Two erm_users created, onyl self is returned without permission to view_any_borrower $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200) ->json_is( [ $librarian->to_api( { user => $librarian } ) ] ); + my $dbh = C4::Context->dbh; + $dbh->do( + q{INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, ?, ?)}, undef, + ( $librarian->borrowernumber, 4, 'view_borrower_infos_from_any_libraries' ) + ); + + # Two erm_users created, they should both be returned + $t->get_ok("//$userid:$password@/api/v1/erm/users")->status_is(200) + ->json_is( + [ $librarian->to_api( { user => $librarian } ), $another_erm_user->to_api( { user => $another_erm_user } ) ] ); + # Warn on unsupported query parameter $t->get_ok("//$userid:$password@/api/v1/erm/users?blah=blah") ->status_is(400) -- 2.39.5