Bugzilla – Attachment 129898 Details for
Bug 29906
When changing hold parameters over API (PUT) it forcibly gets to "suspended" state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29906: fix when hold record forcibly gets unwanted "suspended" state
Bug-29906-fix-when-hold-record-forcibly-gets-unwan.patch (text/plain), 3.15 KB, created by
Jonathan Druart
on 2022-01-27 15:28:49 UTC
(
hide
)
Description:
Bug 29906: fix when hold record forcibly gets unwanted "suspended" state
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-01-27 15:28:49 UTC
Size:
3.15 KB
patch
obsolete
>From 6fb6fd4f440fa0d8af0e41756f6e408c6d1f8a81 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Wed, 19 Jan 2022 18:01:15 +0200 >Subject: [PATCH] Bug 29906: fix when hold record forcibly gets unwanted > "suspended" state > >This code allows for "Perl false" to pass through to $suspended_until >if it is in $hold->suspend_until and in $body->{suspended_until} >But in case of "Perl truth" it calls dt_from_string for that value. > >Reproduction: >1. run provided test in kshell: prove t/db_dependent/api/v1/holds.t >2. see the test fails with something like: > # Failed test 'Location change shouldn't touch suspended status' > # at t/db_dependent/api/v1/holds.t line 1067. > # got: '1' > # expected: '0' > > # Failed test 'suspended_until should be undef' > # at t/db_dependent/api/v1/holds.t line 1068. > # got: '2022-01-20 00:00:00' > # expected: undef > # Looks like you failed 2 tests of 39. >3. apply the changes in this patch to Koha/REST/V1/Holds.pm >4. run provided test in kshell: prove t/db_dependent/api/v1/holds.t >5. test will pass. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/V1/Holds.pm | 4 ++-- > t/db_dependent/api/v1/holds.t | 8 +++++++- > 2 files changed, 9 insertions(+), 3 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 92e6e4774e0..b8d9a5e5aa2 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -282,8 +282,8 @@ sub edit { > # suspended_until can also be set to undef > my $suspended_until = > exists $body->{suspended_until} >- ? dt_from_string( $body->{suspended_until}, 'rfc3339' ) >- : dt_from_string( $hold->suspend_until, 'iso' ); >+ ? $body->{suspended_until} && dt_from_string( $body->{suspended_until}, 'rfc3339' ) >+ : $hold->suspend_until && dt_from_string( $hold->suspend_until, 'iso' ); > > my $params = { > reserve_id => $hold_id, >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index abf23d4fca4..64485f01ac0 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -892,7 +892,7 @@ subtest 'pickup_locations() tests' => sub { > > subtest 'edit() tests' => sub { > >- plan tests => 37; >+ plan tests => 39; > > $schema->storage->txn_begin; > >@@ -1010,6 +1010,8 @@ subtest 'edit() tests' => sub { > branchcode => $library_3->branchcode, > itemnumber => $item->itemnumber, > priority => 1, >+ suspend => 0, >+ suspend_until => undef, > } > } > ); >@@ -1061,7 +1063,11 @@ subtest 'edit() tests' => sub { > $item_hold->discard_changes; > is( $item_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); > >+ is( $item_hold->suspend, 0, 'Location change should not activate suspended status' ); >+ is( $item_hold->suspend_until, undef, 'Location change should keep suspended_until be undef' ); >+ > $schema->storage->txn_rollback; >+ > }; > > subtest 'add() tests' => sub { >-- >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 29906
:
129619
|
129621
|
129622
|
129626
|
129645
|
129650
|
129651
|
129663
|
129666
| 129898 |
129899