@@ -, +, @@
---
Koha/Hold.pm | 8 +--
.../bootstrap/en/includes/holds-table.inc | 2 +-
opac/opac-modrequest.pl | 2 +-
t/db_dependent/Hold.t | 52 +------------------
t/db_dependent/Koha/Hold.t | 50 +++++++++++++++++-
5 files changed, 56 insertions(+), 58 deletions(-)
--- a/Koha/Hold.pm
+++ a/Koha/Hold.pm
@@ -906,15 +906,15 @@ sub to_api_mapping {
};
}
-=head3 can_change_branch_opac
+=head3 can_update_pickup_location_opac
-returns if a hold can change pickup location from opac
+ my $can_update_pickup_location_opac = $hold->can_update_pickup_location_opac;
-my $can_change_branch_opac = $hold->can_change_branch_opac;
+Returns if a hold can change pickup location from opac
=cut
-sub can_change_branch_opac {
+sub can_update_pickup_location_opac {
my ($self) = @_;
my @statuses = split /,/, C4::Context->preference("OPACAllowUserToChangeBranch");
--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/holds-table.inc
@@ -83,7 +83,7 @@
Pickup location:
[% HOLD.branch.branchname | html %]
- [% IF ( HOLD.can_change_branch_opac ) %]
+ [% IF ( HOLD.can_update_pickup_location_opac ) %]
--- a/opac/opac-modrequest.pl
+++ a/opac/opac-modrequest.pl
@@ -60,7 +60,7 @@ if ( $reserve_id && $borrowernumber ) {
}
elsif ( $new_pickup_location ) {
- if ($hold->can_change_branch_opac){
+ if ($hold->can_update_pickup_location_opac) {
$hold->set_pickup_location({ library_id => $new_pickup_location });
}
else {
--- a/t/db_dependent/Hold.t
+++ a/t/db_dependent/Hold.t
@@ -29,7 +29,7 @@ use Koha::Item;
use Koha::DateUtils qw( dt_from_string );
use t::lib::TestBuilder;
-use Test::More tests => 36;
+use Test::More tests => 35;
use Test::Exception;
use Test::Warn;
@@ -386,53 +386,3 @@ subtest 'suspend() tests' => sub {
$schema->storage->txn_rollback;
};
-
-subtest 'can_change_branch_opac() tests' => sub {
-
- plan tests => 8;
-
- $schema->storage->txn_begin;
-
- my $hold = $builder->build_object(
- { class => 'Koha::Holds',
- value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef }
- }
- );
-
- t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' );
- $hold->found(undef);
- is( $hold->can_change_branch_opac, 0, "Pending hold pickup can't be changed (No change allowed)" );
-
- $hold->found('T');
- is( $hold->can_change_branch_opac, 0, "In transit hold pickup can't be changed (No change allowed)" );
-
- $hold->found('W');
- is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" );
-
- $hold->found(undef);
- $dt = dt_from_string();
-
- $hold->suspend_hold( $dt );
- is( $hold->can_change_branch_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" );
- $hold->resume();
-
- t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' );
- $hold->found(undef);
- is( $hold->can_change_branch_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" );
-
- $hold->found('T');
- is( $hold->can_change_branch_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" );
-
- $hold->found('W');
- is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" );
-
- $hold->found(undef);
- $dt = dt_from_string();
- $hold->suspend_hold( $dt );
- is( $hold->can_change_branch_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" );
- $hold->resume();
-
-
- $schema->storage->txn_rollback;
-
-};
--- a/t/db_dependent/Koha/Hold.t
+++ a/t/db_dependent/Koha/Hold.t
@@ -19,7 +19,7 @@
use Modern::Perl;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::Exception;
use Test::MockModule;
@@ -29,6 +29,7 @@ use t::lib::TestBuilder;
use t::lib::Mocks;
use Koha::ActionLogs;
+use Koha::DateUtils qw(dt_from_string);
use Koha::Holds;
use Koha::Libraries;
use Koha::Old::Holds;
@@ -863,3 +864,50 @@ subtest 'cancellation_requestable_from_opac() tests' => sub {
$schema->storage->txn_rollback;
};
+
+subtest 'can_update_pickup_location_opac() tests' => sub {
+
+ plan tests => 8;
+
+ $schema->storage->txn_begin;
+
+ my $hold = $builder->build_object(
+ { class => 'Koha::Holds',
+ value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef }
+ }
+ );
+
+ t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' );
+ $hold->found(undef);
+ is( $hold->can_update_pickup_location_opac, 0, "Pending hold pickup can't be changed (No change allowed)" );
+
+ $hold->found('T');
+ is( $hold->can_update_pickup_location_opac, 0, "In transit hold pickup can't be changed (No change allowed)" );
+
+ $hold->found('W');
+ is( $hold->can_update_pickup_location_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" );
+
+ $hold->found(undef);
+ my $dt = dt_from_string();
+
+ $hold->suspend_hold( $dt );
+ is( $hold->can_update_pickup_location_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" );
+ $hold->resume();
+
+ t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' );
+ $hold->found(undef);
+ is( $hold->can_update_pickup_location_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" );
+
+ $hold->found('T');
+ is( $hold->can_update_pickup_location_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" );
+
+ $hold->found('W');
+ is( $hold->can_update_pickup_location_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" );
+
+ $hold->found(undef);
+ $dt = dt_from_string();
+ $hold->suspend_hold( $dt );
+ is( $hold->can_update_pickup_location_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" );
+
+ $schema->storage->txn_rollback;
+};
--
|