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)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 25 Mar 2022 06:08:50 +0000 (20:08 -1000)
commit398a4b4698c32a234fdc41ed96283881e7fd6cdc
tree77ac1941f9d324b85b6f7c05252cf3592104dd45
parent6f8b94f49c6209ae0815fdbb6ec6aba78e41a22a
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>
Koha/REST/Plugin/Objects.pm