Bug 18409: Make the controller for holds use Koha::Holds
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 21 Apr 2017 23:34:00 +0000 (20:34 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Mon, 24 Apr 2017 13:40:40 +0000 (09:40 -0400)
commit694c09aa873973c4f55b5d90948b1027adc0f1c1
tree6974843069847e9409923d28cde4788e68d24694
parent4eb53eeee9dbf1c4c3a4c6da48148e0a0d27f0fe
Bug 18409: Make the controller for holds use Koha::Holds

Recently, there's been a major fix on the REST api swagger spec,
which involved fixing boolean values so they are actually booleans
and Koha::Object was extended to handle that.
While the swagger spec for this endpoint got fixed, such is not the case
with the implementation (the controller class).

This patch fixes this situation by:
- Specifying boolean properties as boolean in the schema file
- Fixes the controller so it returns Koha::Hold objects instead of the
  hashref returned by GetReserve, which is wrong.
- Better (than empty) descriptions are added to 'suspend',
  'suspend_until' and 'lowestPriority' on the spec.

To test:
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/db_dependent/api/v1/holds.t
=> FAIL: Tests fail, mostly due to error 500 results.
- Apply this patch
- Run:
 k$ prove t/db_dependent/api/v1/holds.t
=> SUCCESS: Tests pass!
- Sign off :-D

This can also be tested using any interface for REST apis.

Note: This endpoint lacks several of the new guidelines and is not
complete (there's no GET for single holds, etc). It is also missing
exception handling. There are probably
other bug reports for that, just thought it was worth mentioning.

Followed test plan and this patch worked as intended
Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Koha/REST/V1/Hold.pm
Koha/Schema/Result/Reserve.pm
api/v1/swagger/definitions/hold.json