Bugzilla – Attachment 155794 Details for
Bug 34333
Add cancellation request information embed option to the holds endpoint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34333: Add Koha::Hold->cancellation_requested
Bug-34333-Add-KohaHold-cancellationrequested.patch (text/plain), 2.58 KB, created by
Martin Renvoize
on 2023-09-18 10:44:03 UTC
(
hide
)
Description:
Bug 34333: Add Koha::Hold->cancellation_requested
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2023-09-18 10:44:03 UTC
Size:
2.58 KB
patch
obsolete
>From 45944a2b44bbfb1f877b37382b6393285d479435 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 20 Jul 2023 20:16:39 -0300 >Subject: [PATCH] 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> >--- > Koha/Hold.pm | 14 ++++++++++++++ > t/db_dependent/Koha/Hold.t | 6 ++++-- > 2 files changed, 18 insertions(+), 2 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index f275530d974..2775e591841 100644 >--- a/Koha/Hold.pm >+++ b/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( >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index cc90dafb899..50d6ffdbe9b 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -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; > }; >-- >2.41.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34333
:
153744
|
153745
|
155735
|
155736
| 155794 |
155795