From a0e4195622dba7ca326dc9ab1d1eaad82869b457 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 2 Aug 2016 19:13:23 +0300 Subject: [PATCH] Bug 16826: [QA Follow-up] Add 'new_status' to Swagger definition Adds missing "new_status" to item's Swagger definition. Also, to avoid forgotten columns in definitions, adds a test to compare item-definition to database's items-table. To test: 1. Run t/db_dependent/api/v1/items.t https://bugs.koha-community.org/show_bug.cgi?id=16825 --- api/v1/definitions/item.json | 4 ++++ t/db_dependent/api/v1/items.t | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/api/v1/definitions/item.json b/api/v1/definitions/item.json index 9c43f85..2422786 100644 --- a/api/v1/definitions/item.json +++ b/api/v1/definitions/item.json @@ -172,6 +172,10 @@ "stocknumber": { "type": ["string", "null"], "description": "inventory number" + }, + "new_status": { + "type": ["string", "null"], + "description": "'new' value, whatever free-text information." } } } diff --git a/t/db_dependent/api/v1/items.t b/t/db_dependent/api/v1/items.t index 0536e0f..56e76d5 100644 --- a/t/db_dependent/api/v1/items.t +++ b/t/db_dependent/api/v1/items.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 12; +use Test::More tests => 13; use Test::Mojo; use t::lib::TestBuilder; @@ -34,6 +34,23 @@ use Koha::Items; my $builder = t::lib::TestBuilder->new(); +subtest 'Swagger item-definition and Koha::Item' => sub { + plan tests => 2; + + use_ok("Swagger2"); + my $swagger = Swagger2->new(C4::Context->config('intranetdir')."/api/v1/swagger.json")->expand; + my $api_spec = $swagger->api_spec->data; + + my $properties = $api_spec->{definitions}->{"item"}->{properties}; + my @columns = Koha::Item->new->_result->columns; + my @missing; + foreach my $column (@columns) { + push @missing, $column unless $properties->{$column}; + } + + is(join(', ' , @missing), "", "Item definition up-to-date with Koha::Item columns."); +}; + my $dbh = C4::Context->dbh; $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; -- 1.9.1