Bug 33440: Tests

Test Plan
1. Staff member A creates a public list.
2. Staff member A transfers this public list to another staff member (staff member b) without list permissions.
3. Staff Member B now has the ability to edit this public list and add/remove items from this list.
4. Apply the patch
5. Repeat steps 1 and 2. An error message should now appear stating that the “Transfer not allowed: You or the selected user do not have the required permissions.”
6. Provide the correct permissions to Staff Member B. Initiate the transfer again. The transfer should be successful.
7. Test these steps in the OPAC as well.
8. Prove t/db_dependent/Virtualshelves.t
9. Sign off and have a wonderful day! :D

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 45c7020220)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Laura_Escamilla 2025-04-22 16:27:50 +00:00 committed by Paul Derscheid
parent 831a8bf9b8
commit 7ed45d8d15
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 23 additions and 3 deletions

View File

@ -1355,7 +1355,7 @@ subtest 'Get shelves containing biblios' => sub {
};
subtest 'cannot_be_transferred' => sub {
plan tests => 12;
plan tests => 13;
# Three patrons and a deleted one
my $staff = $builder->build_object( { class => 'Koha::Patrons', value => { flags => undef } } );
@ -1379,6 +1379,24 @@ subtest 'cannot_be_transferred' => sub {
$public_list->cannot_be_transferred( { by => $staff->id, to => $receiver->id } ), 'unauthorized_transfer',
'Lacks permission'
);
# Give recipient MINIMUM permission
$builder->build(
{
source => 'UserPermission',
value => {
borrowernumber => $receiver->id,
module_bit => 20,
code => 'edit_public_list_contents',
}
}
);
is(
$public_list->cannot_be_transferred( { by => $staff->id, to => $receiver->id } ),
'unauthorized_transfer',
'Recipient lacks necessary permissions to own public list'
);
my $perms = $builder->build(
{
source => 'UserPermission',
@ -1387,9 +1405,11 @@ subtest 'cannot_be_transferred' => sub {
}
}
);
is(
$public_list->cannot_be_transferred( { by => $staff->id, to => $receiver->id } ), 0,
'Minimum permission passes'
$public_list->cannot_be_transferred( { by => $staff->id, to => $receiver->id } ),
0,
'Recipient with minimum required permission can accept ownership'
);
$staff->flags(1)->store;
is(