From c16a9d2ca7c4b259c3a831aa656c582b7b333d3a Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 30 Jul 2014 16:28:14 +0200 Subject: [PATCH] Bug 7290: QA fixes 1) Use the new isSuperlibrarian instead of $userflags->{superlibrarian} 2) Fix capitalization of "Duplicate Barcode" 3) Add comments in t/Acquisition/CanUserReceiveBasket.t --- C4/Acquisition.pm | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt | 2 +- t/Acquisition/CanUserReceiveBasket.t | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index e456e8f..349ed25 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -869,7 +869,7 @@ sub CanUserReceiveOrder { my $branch = C4::Context->userenv->{'branch'}; - unless ($userflags->{superlibrarian} + unless (C4::Context->IsSuperLibrarian() || (!ref $userflags->{acquisition} && $userflags->{acquisition}) || (ref $userflags->{acquisition} && $userflags->{acquisition}->{order_receive_all}) ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 2260046..46c998f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -157,7 +157,7 @@
  • [% error.error_param %] [% IF ( error.error_duplicate_barcode ) %] - Duplicate Barcode + Duplicate barcode [% ELSIF (error.error_cannot_receive_order) %] You were not authorised to receive this order [% END %] diff --git a/t/Acquisition/CanUserReceiveBasket.t b/t/Acquisition/CanUserReceiveBasket.t index f0a7453..b0eb385 100644 --- a/t/Acquisition/CanUserReceiveBasket.t +++ b/t/Acquisition/CanUserReceiveBasket.t @@ -37,28 +37,36 @@ my $order3 = { $userenv->{branch} = 'B1'; +# User can receive any orders thanks to his permissions ok( CanUserReceiveOrder($borrower, $order1, {superlibrarian => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive_all => 1 }}) ); +# User cannot receive any order because of his lack of permission ok( not CanUserReceiveOrder($borrower, $order1, {}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => 0}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 0 }}) ); +# User with order_receive permission can receive only orders of his branch (B1) +# and orders that don't belong to any branch ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) ); ok( CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) ); ok( not CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) ); $userenv->{branch} = 'B2'; +# User can receive any order thanks to his permissions ok( CanUserReceiveOrder($borrower, $order1, {superlibrarian => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive_all => 1 }}) ); +# User cannot receive any order because of his lack of permission ok( not CanUserReceiveOrder($borrower, $order1, {}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => 0}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 0 }}) ); +# User with order_receive permission can receive only orders of his branch (B2) +# and orders that don't belong to any branch ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) ); ok( not CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) ); ok( CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) ); -- 1.9.1