Bug 34333: Add Koha::Hold->cancellation_requested
This patch adds a helper method for telling if a hold has cancellation requests. To be used for embedding such information. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Hold.t => SUCCESS: Tests pass, the new method is covered by tests. 3. Sign off :-D Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
ac7581e90a
commit
23cfdf97e3
2 changed files with 18 additions and 2 deletions
14
Koha/Hold.pm
14
Koha/Hold.pm
|
@ -645,6 +645,20 @@ sub cancellation_requests {
|
|||
return Koha::Hold::CancellationRequests->search( { hold_id => $self->id } );
|
||||
}
|
||||
|
||||
=head3 cancellation_requested
|
||||
|
||||
if ( $hold->cancellation_requested ) { ... }
|
||||
|
||||
Returns true if a cancellation request has been placed for the hold.
|
||||
|
||||
=cut
|
||||
|
||||
sub cancellation_requested {
|
||||
my ($self) = @_;
|
||||
|
||||
return Koha::Hold::CancellationRequests->search( { hold_id => $self->id } )->count > 0;
|
||||
}
|
||||
|
||||
=head3 cancel
|
||||
|
||||
my $cancel_hold = $hold->cancel(
|
||||
|
|
|
@ -728,9 +728,9 @@ subtest 'suspend_hold() and resume() tests' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'cancellation_requests() and add_cancellation_request() tests' => sub {
|
||||
subtest 'cancellation_requests(), add_cancellation_request() and cancellation_requested() tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 6;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
@ -739,6 +739,7 @@ subtest 'cancellation_requests() and add_cancellation_request() tests' => sub {
|
|||
my $hold = $builder->build_object( { class => 'Koha::Holds', } );
|
||||
|
||||
is( $hold->cancellation_requests->count, 0 );
|
||||
ok( !$hold->cancellation_requested );
|
||||
|
||||
# Add two cancellation requests
|
||||
my $request_1 = $hold->add_cancellation_request;
|
||||
|
@ -756,6 +757,7 @@ subtest 'cancellation_requests() and add_cancellation_request() tests' => sub {
|
|||
is( $request_2->creation_date, $creation_date, 'Passed creation_date set' );
|
||||
|
||||
is( $hold->cancellation_requests->count, 2 );
|
||||
ok( $hold->cancellation_requested );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue