Bugzilla – Attachment 121679 Details for
Bug 27064
Transferring an item with a hold allows the user to set a hold waiting without transferring to the correct branch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27064: (QA follow-up) Pass 'replace' through to Koha::Item::Transfer->cancel
Bug-27064-QA-follow-up-Pass-replace-through-to-Koh.patch (text/plain), 4.65 KB, created by
Joonas Kylmälä
on 2021-06-07 14:44:53 UTC
(
hide
)
Description:
Bug 27064: (QA follow-up) Pass 'replace' through to Koha::Item::Transfer->cancel
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2021-06-07 14:44:53 UTC
Size:
4.65 KB
patch
obsolete
>From 01a3430aab7fbce365d23be2fdca9e9cf97aec41 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 6 May 2021 16:31:39 +0100 >Subject: [PATCH] Bug 27064: (QA follow-up) Pass 'replace' through to > Koha::Item::Transfer->cancel >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >The `replace` option found in Koha::Item->request_transfer should be >passed through to Koha::Item::Transfer->cancel and prevent any reverse >transfers from being queued in such cases. > >This prevents modItemTransfer from adding superflous reverse transfers >whenever it is used. > >Test plan >1/ Run t/db_dependent/Koha/Item.t to prove the new tests pass > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > Koha/Item.pm | 2 +- > Koha/Item/Transfer.pm | 3 ++- > t/db_dependent/Koha/Item.t | 27 ++++++++++++++++++++++++--- > 3 files changed, 27 insertions(+), 5 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 2bad020287..730a73bc8d 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -467,7 +467,7 @@ sub request_transfer { > } > )->store(); > >- $request->cancel( { reason => $params->{reason}, force => 1 } ) >+ $request->cancel( { reason => $params->{reason}, force => 1, replace => 1 } ) > if ( defined($request) && $params->{replace} ); > > return $transfer; >diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm >index 4112b3fab9..21d8a2938c 100644 >--- a/Koha/Item/Transfer.pm >+++ b/Koha/Item/Transfer.pm >@@ -159,9 +159,10 @@ sub cancel { > ->store; > > # Set up return transfer if transfer was force cancelled whilst in transit >+ # and we were not notified that the transfer is being replaced. > # NOTE: We don't catch here, as we're happy to fail if there are already > # other transfers in the queue. >- if ($in_transit) { >+ if ($in_transit && !$params->{replace}) { > try { > $self->item->request_transfer( > { to => $self->from_library, reason => 'TransferCancellation' } ); >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index a894048b1e..161a13b575 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -459,7 +459,7 @@ subtest 'pickup_locations' => sub { > }; > > subtest 'request_transfer' => sub { >- plan tests => 7; >+ plan tests => 13; > $schema->storage->txn_begin; > > my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); >@@ -485,6 +485,7 @@ subtest 'request_transfer' => sub { > is( ref($transfer), 'Koha::Item::Transfer', > 'Koha::Item->request_transfer should return a Koha::Item::Transfer object' > ); >+ my $original_transfer = $transfer->get_from_storage; > > # Transfer already in progress > throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) } >@@ -496,7 +497,27 @@ subtest 'request_transfer' => sub { > 'Koha::Item::Transfer', > 'The exception contains the found Koha::Item::Transfer' ); > >- $transfer->datearrived(dt_from_string)->store(); >+ # Queue transfer >+ my $queued_transfer = $item->request_transfer( >+ { to => $library2, reason => 'Manual', enqueue => 1 } ); >+ is( ref($queued_transfer), 'Koha::Item::Transfer', >+ 'Koha::Item->request_transfer allowed when enqueue is set' ); >+ my $transfers = $item->get_transfers; >+ is($transfers->count, 2, "There are now 2 live transfers in the queue"); >+ $transfer = $transfer->get_from_storage; >+ is_deeply($transfer->unblessed, $original_transfer->unblessed, "Original transfer unchanged"); >+ $queued_transfer->datearrived(dt_from_string)->store(); >+ >+ # Replace transfer >+ my $replaced_transfer = $item->request_transfer( >+ { to => $library2, reason => 'Manual', replace => 1 } ); >+ is( ref($replaced_transfer), 'Koha::Item::Transfer', >+ 'Koha::Item->request_transfer allowed when replace is set' ); >+ $original_transfer->discard_changes; >+ ok($original_transfer->datecancelled, "Original transfer cancelled"); >+ $transfers = $item->get_transfers; >+ is($transfers->count, 1, "There is only 1 live transfer in the queue"); >+ $replaced_transfer->datearrived(dt_from_string)->store(); > > # BranchTransferLimits > t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); >@@ -513,7 +534,7 @@ subtest 'request_transfer' => sub { > > my $forced_transfer = $item->request_transfer( { to => $library1, reason => 'Manual', ignore_limits => 1 } ); > is( ref($forced_transfer), 'Koha::Item::Transfer', >- 'Koha::Item->request_transfer allowed when forced' >+ 'Koha::Item->request_transfer allowed when ignore_limits is set' > ); > > $schema->storage->txn_rollback; >-- >2.25.1
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 27064
:
113877
|
114712
|
120222
|
120759
|
120764
|
121065
|
121066
|
121067
|
121090
|
121091
|
121092
|
121093
|
121141
|
121142
|
121143
|
121144
|
121670
|
121671
|
121672
|
121673
|
121674
|
121675
|
121676
|
121677
|
121678
|
121679
|
121680
|
121681
|
121682
|
121683
|
121684
|
121685
|
121981