Bugzilla – Attachment 171726 Details for
Bug 37256
Add an endpoint to allow setting circulation rule sets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37256: Ensure empty and null work as expected in PUT
Bug-37256-Ensure-empty-and-null-work-as-expected-i.patch (text/plain), 2.66 KB, created by
Martin Renvoize (ashimema)
on 2024-09-19 13:16:46 UTC
(
hide
)
Description:
Bug 37256: Ensure empty and null work as expected in PUT
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-09-19 13:16:46 UTC
Size:
2.66 KB
patch
obsolete
>From 36e97b40231883057c0a5fbb0d1c97dac96b2c21 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 9 Aug 2024 15:40:43 +0100 >Subject: [PATCH] Bug 37256: Ensure empty and null work as expected in PUT > >Sponsored-by: Glasgow Colleges Library Group <https://library.cityofglasgowcollege.ac.uk> >Signed-off-by: George Harkins <George.Harkins@cityofglasgowcollege.ac.uk> >--- > Koha/CirculationRules.pm | 5 +++++ > t/db_dependent/api/v1/circulation_rules.t | 18 +++++++++++++++++- > 2 files changed, 22 insertions(+), 1 deletion(-) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index d558c1e7810..c45d2ccc5aa 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -416,6 +416,7 @@ sub set_rule { > $rule->update(); > } > else { >+ $rule->rule_value(undef); > $rule->delete(); > } > } >@@ -439,6 +440,10 @@ sub set_rule { > $memory_cache->clear_from_cache($k) if $k =~ m{^CircRules:}; > } > >+ $rule = Koha::CirculationRule->new( >+ { rule_name => $rule_name, branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype } ) >+ unless $rule; >+ > return $rule; > } > >diff --git a/t/db_dependent/api/v1/circulation_rules.t b/t/db_dependent/api/v1/circulation_rules.t >index d83e7af48ef..4b867482822 100755 >--- a/t/db_dependent/api/v1/circulation_rules.t >+++ b/t/db_dependent/api/v1/circulation_rules.t >@@ -290,7 +290,7 @@ subtest 'list_rules() tests' => sub { > }; > > subtest 'set_rules() tests' => sub { >- plan tests => 23; >+ plan tests => 28; > > $schema->storage->txn_begin; > >@@ -388,5 +388,21 @@ subtest 'set_rules() tests' => sub { > is( $json->{fine}, 10, "Fine rule set correctly for wildcard context" ); > is( $json->{finedays}, 7, "Finedays rule set correctly for wildcard context" ); > >+ # Setting rules empty and undefined >+ note("Setting rules to empty and undefined"); >+ $rules_to_set->{fine} = ''; >+ $rules_to_set->{finedays} = undef; >+ $t->put_ok( "//$userid:$password@/api/v1/circulation_rules" => json => $rules_to_set )->status_is(200); >+ >+ # Verify the rules were updated >+ $json = $t->tx->res->json; >+ is( $json->{fine}, '', "Fine rule updated correctly" ); >+ is( $json->{finedays}, undef, "Finedays rule remains the same" ); >+ >+ # Verify that the explicit undef results in a rule deletion >+ my $rules = Koha::CirculationRules->search( >+ { categorycode => undef, branchcode => undef, itemtype => undef, rule_name => 'finedays' } ); >+ is( $rules->count, 0, "Finedays rule deleted from database" ); >+ > $schema->storage->txn_rollback; > }; >-- >2.46.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 37256
:
170000
|
170001
|
170128
|
170129
|
170130
|
170152
|
170153
|
170154
|
170335
|
170336
|
170337
|
170338
|
171719
|
171720
|
171721
|
171722
|
171723
|
171724
|
171725
|
171726
|
176728
|
176729
|
176730
|
176731