Bug 30165: (follow-up) Allow objects.search usage outside OpenAPI
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 24 Mar 2022 12:52:04 +0000 (09:52 -0300)
committerKyle Hall <kyle@bywatersolutions.com>
Fri, 25 Mar 2022 14:41:01 +0000 (10:41 -0400)
commit2550b3b60889e113e02cb1a69ff31c08927c4d95
treeee5262d550891d7344f44e7be5d20edc432a017c
parent7d6f32a4f44a13e032f9bc29e28706be792aacbe
Bug 30165: (follow-up) Allow objects.search usage outside OpenAPI

Our objects.search helper is written for being used in our API
controllers, which get their query parameters processed by the OpenAPI
plugin, using JSON::Validator.

Particularly, the 'q' parameter is defined as 'multi' on our spec, which
means objects.search always gets it as an arrayref.

As the Objects.t tests are not using the OpenAPI plugin, a hashref is
generated as only one q= is being passed. This patch adds an extra
validation on objects.search, for the non-arrayref use case and does the
right thing.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t
=> FAIL: Tests fail!
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass!
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Koha/REST/Plugin/Objects.pm