From 986d417a7f98243ef46d43732c6c91918ac2fb0c Mon Sep 17 00:00:00 2001 From: Laura_Escamilla Date: Tue, 22 Apr 2025 16:27:50 +0000 Subject: [PATCH] Bug 33440: Tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Baptiste Wojtkowski --- t/db_dependent/Virtualshelves.t | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t index 1df952df..10182dfb 100755 --- a/t/db_dependent/Virtualshelves.t +++ b/t/db_dependent/Virtualshelves.t @@ -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( -- 2.30.2