From 2725d3156a99d304422119c340f25c89dd7b4e3b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 8 Nov 2017 16:08:01 -0300 Subject: [PATCH] Bug 7317: (QA followup) Rename 'branch' for 'library' Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/Illrequest.pm | 4 ++-- api/v1/swagger/paths/illrequests.json | 2 +- t/db_dependent/Illrequests.t | 10 +++++----- t/db_dependent/api/v1/illrequests.t | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 01a870d290..b6585c23ab 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -1018,8 +1018,8 @@ sub TO_JSON { $object->{capabilities} = $self->capabilities; } # Augment the request response with library details if appropriate - if ( $embed->{branch} ) { - $object->{branch} = Koha::Libraries->find( + if ( $embed->{library} ) { + $object->{library} = Koha::Libraries->find( $self->branchcode )->TO_JSON; } diff --git a/api/v1/swagger/paths/illrequests.json b/api/v1/swagger/paths/illrequests.json index 5372cb9d09..48f61fde31 100644 --- a/api/v1/swagger/paths/illrequests.json +++ b/api/v1/swagger/paths/illrequests.json @@ -15,7 +15,7 @@ "type": "string", "enum": [ "patron", - "branch", + "library", "capabilities", "metadata" ] diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t index 4259a70fec..761de9f12b 100644 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Illrequests.t @@ -837,11 +837,11 @@ subtest 'TO_JSON() tests' => sub { undef, '%embed not passed, no \'metadata\' attribute' ); is( $illreq_json->{capabilities}, undef, '%embed not passed, no \'capabilities\' attribute' ); - is( $illreq_json->{branch}, - undef, '%embed not passed, no \'branch\' attribute' ); + is( $illreq_json->{library}, + undef, '%embed not passed, no \'library\' attribute' ); $illreq_json = $illreq->TO_JSON( - { patron => 1, metadata => 1, capabilities => 1, branch => 1 } ); + { patron => 1, metadata => 1, capabilities => 1, library => 1 } ); is( $illreq_json->{patron}->{firstname}, $patron->firstname, '%embed passed, \'patron\' attribute correct (firstname)' ); @@ -855,8 +855,8 @@ subtest 'TO_JSON() tests' => sub { 'metawhat?', '%embed passed, \'metadata\' attribute correct' ); is( $illreq_json->{capabilities}, 'capable', '%embed passed, \'capabilities\' attribute correct' ); - is( $illreq_json->{branch}->{branchcode}, - $library->branchcode, '%embed not passed, no \'branch\' attribute' ); + is( $illreq_json->{library}->{branchcode}, + $library->branchcode, '%embed not passed, no \'library\' attribute' ); $schema->storage->txn_rollback; }; diff --git a/t/db_dependent/api/v1/illrequests.t b/t/db_dependent/api/v1/illrequests.t index cd1b04a1d6..b0850e9192 100644 --- a/t/db_dependent/api/v1/illrequests.t +++ b/t/db_dependent/api/v1/illrequests.t @@ -81,13 +81,13 @@ subtest 'list() tests' => sub { # One illrequest created, returned with augmented data $tx = $t->ua->build_tx( GET => - '/api/v1/illrequests?embed=patron,branch,capabilities,metadata' ); + '/api/v1/illrequests?embed=patron,library,capabilities,metadata' ); $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); $tx->req->env( { REMOTE_ADDR => $remote_address } ); $t->request_ok($tx)->status_is(200)->json_is( [ $illrequest->TO_JSON( - { patron => 1, branch => 1, capabilities => 1, metadata => 1 } + { patron => 1, library => 1, capabilities => 1, metadata => 1 } ) ] ); -- 2.39.5