Bugzilla – Attachment 169025 Details for
Bug 36641
Add an endpoint to list circulation rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36641: (follow-up) Ensure limited return works
Bug-36641-follow-up-Ensure-limited-return-works.patch (text/plain), 3.57 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-07-15 19:01:15 UTC
(
hide
)
Description:
Bug 36641: (follow-up) Ensure limited return works
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-07-15 19:01:15 UTC
Size:
3.57 KB
patch
obsolete
>From a538f1e904626a8fd4052d0ed4a5ddce4c5ad0cb Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Sat, 13 Jul 2024 13:12:09 +0100 >Subject: [PATCH] Bug 36641: (follow-up) Ensure limited return works > >We have a ?rules=a,b parameter available for specifying a subset of >rules in the set to return. This patch adds a test to confirm that works >(and fixes the controller and specification as the test proved it wasn't >working) > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/CirculationRules.pm | 5 ++++- > api/v1/swagger/paths/circulation_rules.yaml | 5 +---- > t/db_dependent/api/v1/circulation_rules.t | 8 ++++++-- > 3 files changed, 11 insertions(+), 7 deletions(-) > >diff --git a/Koha/REST/V1/CirculationRules.pm b/Koha/REST/V1/CirculationRules.pm >index 320be889611..41cb1cdf06a 100644 >--- a/Koha/REST/V1/CirculationRules.pm >+++ b/Koha/REST/V1/CirculationRules.pm >@@ -51,7 +51,10 @@ sub list_rules { > > return try { > my $effective = $c->param('effective') // 1; >- my $kinds = $c->param('rules') // [ keys %{ Koha::CirculationRules->rule_kinds } ]; >+ my $kinds = >+ defined( $c->param('rules') ) >+ ? [ split /\s*,\s*/, $c->param('rules') ] >+ : [ keys %{ Koha::CirculationRules->rule_kinds } ]; > my $item_type = $c->param('item_type_id'); > my $branchcode = $c->param('library_id'); > my $patron_category = $c->param('patron_category_id'); >diff --git a/api/v1/swagger/paths/circulation_rules.yaml b/api/v1/swagger/paths/circulation_rules.yaml >index 1c146682201..eeba8a20b4f 100644 >--- a/api/v1/swagger/paths/circulation_rules.yaml >+++ b/api/v1/swagger/paths/circulation_rules.yaml >@@ -33,10 +33,7 @@ > in: query > description: A comma-separated list of rule kinds > required: false >- type: array >- items: >- type: string >- collectionFormat: multi >+ type: string > responses: > "200": > description: A list of rules for this item type, library and patron category combination >diff --git a/t/db_dependent/api/v1/circulation_rules.t b/t/db_dependent/api/v1/circulation_rules.t >index da9913bb6cb..8be6e47fa4d 100755 >--- a/t/db_dependent/api/v1/circulation_rules.t >+++ b/t/db_dependent/api/v1/circulation_rules.t >@@ -36,7 +36,7 @@ subtest 'list_rules() tests' => sub { > > my $expected_rules = [ keys %{ Koha::CirculationRules->rule_kinds } ]; > >- plan tests => ( scalar( @{$expected_rules} ) * 2 ) + 36; >+ plan tests => ( scalar( @{$expected_rules} ) * 2 ) + 39; > > $schema->storage->txn_begin; > >@@ -139,9 +139,13 @@ subtest 'list_rules() tests' => sub { > ); > > $t->get_ok("//$userid:$password@/api/v1/circulation_rules")->status_is(200) >- ->json_is( '/0/fine' => 2, "Defaul fine rule returned when no library is added to request query" ) >+ ->json_is( '/0/fine' => 2, "Default fine rule returned when no library is added to request query" ) > ->json_is( '/0/finedays' => 5, "Default finedays rule returned when no library is added to request query" ); > >+ # Limit to only rules we're interested in >+ $t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules=fine,finedays")->status_is(200) >+ ->json_is( '/0' => { fine => 2, finedays => 5 }, "Only the two rules we asked for are returned" ); >+ > # Warn on unsupported query parameter > $t->get_ok("//$userid:$password@/api/v1/circulation_rules?rules_blah=blah")->status_is(400) > ->json_is( [ { path => '/query/rules_blah', message => 'Malformed query string' } ] ); >-- >2.45.2
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 36641
:
165086
|
167937
|
167938
|
167946
|
167947
|
168018
|
168019
|
168020
|
168023
|
168024
|
168025
|
168365
|
168366
|
168367
|
168368
|
168369
|
168370
|
168378
|
168379
|
168395
|
168396
|
168397
|
168398
|
168399
|
168400
|
168401
|
168841
|
168874
|
168875
|
168876
|
168877
|
168878
|
168879
|
168880
|
168881
|
168882
|
168883
|
168884
|
168905
|
168906
|
168907
|
168908
|
168909
|
168910
|
168911
|
168912
|
168913
|
168914
|
168915
|
168916
|
168926
|
168927
|
168928
|
168929
|
168930
|
168931
|
168932
|
168933
|
168934
|
168935
|
168936
|
168937
|
168938
|
168940
|
169013
|
169014
|
169015
|
169016
|
169017
|
169018
|
169019
|
169020
|
169021
|
169022
|
169023
|
169024
| 169025 |
169026