From 799054e3a64d7c897246ae87685391646f1de090 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Wed, 12 Oct 2016 14:29:26 +0300 Subject: [PATCH] [SIGNED-OFF] Bug 17431 - Fix failing test t/db_dependent/api/v1/holds.t This patch fixed failing test for t/db_dependent/api/v1/holds.t which was broken after Bug 14695. $ perl t/db_dependent/api/v1/holds.t ... not ok 42 - similar match for JSON Pointer "/error" # Failed test 'similar match for JSON Pointer "/error"' # at t/db_dependent/api/v1/holds.t line 291. # 'Reserve cannot be placed. Reason: itemAlreadyOnHold' # doesn't match '(?^u:tooManyReserves)' # Looks like you failed 1 test of 42. not ok 4 - Test endpoints with permission To test: 1. Run t/db_dependent/api/v1/holds.t and observe it fail. 2. Apply patch. 3. Run the test again and observe it pass. Signed-off-by: Marc Signed-off-by: Jonathan Druart Signed-off-by: Josef Moravec --- t/db_dependent/api/v1/holds.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index 8a5f393..184beff 100644 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -110,6 +110,9 @@ $session3->flush; my $biblionumber = create_biblio('RESTful Web APIs'); my $itemnumber = create_item($biblionumber, 'TEST000001'); +my $biblionumber2 = create_biblio('RESTful Web APIs'); +my $itemnumber2 = create_item($biblionumber2, 'TEST000002'); + $dbh->do('DELETE FROM reserves'); my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber, @@ -204,7 +207,7 @@ subtest "Test endpoints without permission, but accessing own object" => sub { }; subtest "Test endpoints with permission" => sub { - plan tests => 42; + plan tests => 45; $tx = $t->ua->build_tx(GET => '/api/v1/holds'); $tx->req->cookies({name => 'CGISESSID', value => $session->id}); @@ -290,6 +293,14 @@ subtest "Test endpoints with permission" => sub { $tx->req->cookies({name => 'CGISESSID', value => $session3->id}); $t->request_ok($tx) ->status_is(403) + ->json_like('/error', qr/itemAlreadyOnHold/); + + $post_data->{biblionumber} = int($biblionumber2); + $post_data->{itemnumber} = int($itemnumber2); + $tx = $t->ua->build_tx(POST => "/api/v1/holds" => json => $post_data); + $tx->req->cookies({name => 'CGISESSID', value => $session3->id}); + $t->request_ok($tx) + ->status_is(403) ->json_like('/error', qr/tooManyReserves/); }; -- 2.1.4