From 06bd256019f519124676719db976d4f6e8258131 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 24 Sep 2019 11:39:17 -0300 Subject: [PATCH] Bug 23517: (follow-up) AddReserve expects a priority parameter Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- t/db_dependent/api/v1/holds.t | 62 +++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index b0a5a191a7..099757934c 100644 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -354,6 +354,7 @@ subtest 'PUT /holds/{hold_id}/priority tests' => sub { my $password = 'AbcdEFG123'; + my $library = $builder->build_object({ class => 'Koha::Libraries' }); my $patron_np = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } ); $patron_np->set_password( { password => $password, skip_validation => 1 } ); @@ -378,45 +379,48 @@ subtest 'PUT /holds/{hold_id}/priority tests' => sub { t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); - my $biblio = $builder->build_sample_biblio; - - my $hold_1 = $builder->build_object( + my $biblio = $builder->build_sample_biblio; + my $patron_1 = $builder->build_object( { - class => 'Koha::Holds', - value => { - suspend => 0, - suspend_until => undef, - waitingdate => undef, - biblionumber => $biblio->biblionumber, - priority => 1 - } + class => 'Koha::Patrons', + value => { branchcode => $library->branchcode } } ); - my $hold_2 = $builder->build_object( + my $patron_2 = $builder->build_object( { - class => 'Koha::Holds', - value => { - suspend => 0, - suspend_until => undef, - waitingdate => undef, - biblionumber => $biblio->biblionumber, - priority => 2 - } + class => 'Koha::Patrons', + value => { branchcode => $library->branchcode } } ); - my $hold_3 = $builder->build_object( + my $patron_3 = $builder->build_object( { - class => 'Koha::Holds', - value => { - suspend => 0, - suspend_until => undef, - waitingdate => undef, - biblionumber => $biblio->biblionumber, - priority => 3 - } + class => 'Koha::Patrons', + value => { branchcode => $library->branchcode } } ); + my $hold_1 = Koha::Holds->find( + AddReserve( + $library->branchcode, $patron_1->borrowernumber, + $biblio->biblionumber, undef, + 1 + ) + ); + my $hold_2 = Koha::Holds->find( + AddReserve( + $library->branchcode, $patron_2->borrowernumber, + $biblio->biblionumber, undef, + 2 + ) + ); + my $hold_3 = Koha::Holds->find( + AddReserve( + $library->branchcode, $patron_3->borrowernumber, + $biblio->biblionumber, undef, + 3 + ) + ); + $t->put_ok( "//$userid_np:$password@/api/v1/holds/" . $hold_3->id . "/priority" => json => 1 )->status_is(403); -- 2.39.5