Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 5; |
20 |
use Test::More tests => 6; |
21 |
use Test::Mojo; |
21 |
use Test::Mojo; |
22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 405-410
subtest 'suspend and resume tests' => sub {
Link Here
|
405 |
$schema->storage->txn_rollback; |
405 |
$schema->storage->txn_rollback; |
406 |
}; |
406 |
}; |
407 |
|
407 |
|
|
|
408 |
subtest 'PUT /holds/{hold_id}/priority tests' => sub { |
409 |
|
410 |
plan tests => 8; |
411 |
|
412 |
$schema->storage->txn_begin; |
413 |
|
414 |
my $password = 'AbcdEFG123'; |
415 |
|
416 |
my $patron_np = $builder->build_object( |
417 |
{ class => 'Koha::Patrons', value => { flags => 0 } } ); |
418 |
$patron_np->set_password( { password => $password, skip_validation => 1 } ); |
419 |
my $userid_np = $patron_np->userid; |
420 |
|
421 |
my $patron = $builder->build_object( |
422 |
{ class => 'Koha::Patrons', value => { flags => 0 } } ); |
423 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
424 |
my $userid = $patron->userid; |
425 |
$builder->build( |
426 |
{ |
427 |
source => 'UserPermission', |
428 |
value => { |
429 |
borrowernumber => $patron->borrowernumber, |
430 |
module_bit => 6, |
431 |
code => 'modify_holds_priority', |
432 |
}, |
433 |
} |
434 |
); |
435 |
|
436 |
# Disable logging |
437 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
438 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
439 |
|
440 |
my $biblio = $builder->build_sample_biblio; |
441 |
|
442 |
my $hold_1 = $builder->build_object( |
443 |
{ |
444 |
class => 'Koha::Holds', |
445 |
value => { |
446 |
suspend => 0, |
447 |
suspend_until => undef, |
448 |
waitingdate => undef, |
449 |
biblionumber => $biblio->biblionumber, |
450 |
priority => 1 |
451 |
} |
452 |
} |
453 |
); |
454 |
my $hold_2 = $builder->build_object( |
455 |
{ |
456 |
class => 'Koha::Holds', |
457 |
value => { |
458 |
suspend => 0, |
459 |
suspend_until => undef, |
460 |
waitingdate => undef, |
461 |
biblionumber => $biblio->biblionumber, |
462 |
priority => 2 |
463 |
} |
464 |
} |
465 |
); |
466 |
my $hold_3 = $builder->build_object( |
467 |
{ |
468 |
class => 'Koha::Holds', |
469 |
value => { |
470 |
suspend => 0, |
471 |
suspend_until => undef, |
472 |
waitingdate => undef, |
473 |
biblionumber => $biblio->biblionumber, |
474 |
priority => 3 |
475 |
} |
476 |
} |
477 |
); |
478 |
|
479 |
$t->put_ok( "//$userid_np:$password@/api/v1/holds/" |
480 |
. $hold_3->id |
481 |
. "/priority" => json => 1 )->status_is(403); |
482 |
|
483 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" |
484 |
. $hold_3->id |
485 |
. "/priority" => json => 1 )->status_is(200)->json_is(1); |
486 |
|
487 |
is( $hold_1->discard_changes->priority, 2, 'Priority adjusted correctly' ); |
488 |
is( $hold_2->discard_changes->priority, 3, 'Priority adjusted correctly' ); |
489 |
is( $hold_3->discard_changes->priority, 1, 'Priority adjusted correctly' ); |
490 |
|
491 |
$schema->storage->txn_rollback; |
492 |
}; |
493 |
|
408 |
sub create_biblio { |
494 |
sub create_biblio { |
409 |
my ($title) = @_; |
495 |
my ($title) = @_; |
410 |
|
496 |
|
411 |
- |
|
|