Lines 358-364
$schema->storage->txn_rollback;
Link Here
|
358 |
|
358 |
|
359 |
subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub { |
359 |
subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub { |
360 |
|
360 |
|
361 |
plan tests => 12; |
361 |
plan tests => 16; |
362 |
|
362 |
|
363 |
$schema->storage->txn_begin; |
363 |
$schema->storage->txn_begin; |
364 |
|
364 |
|
Lines 373-387
subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub {
Link Here
|
373 |
$patron->discard_changes; |
373 |
$patron->discard_changes; |
374 |
my $userid = $patron->userid; |
374 |
my $userid = $patron->userid; |
375 |
|
375 |
|
|
|
376 |
my $renegade_library = $builder->build_object({ class => 'Koha::Libraries' }); |
377 |
|
376 |
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); |
378 |
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); |
377 |
|
379 |
|
378 |
# Make sure pickup location checks doesn't get in the middle |
380 |
# Make sure pickup location checks doesn't get in the middle |
379 |
my $mock_biblio = Test::MockModule->new('Koha::Biblio'); |
381 |
my $mock_biblio = Test::MockModule->new('Koha::Biblio'); |
380 |
$mock_biblio->mock( 'pickup_locations', |
382 |
$mock_biblio->mock( 'pickup_locations', |
381 |
sub { return Koha::Libraries->search; } ); |
383 |
sub { return Koha::Libraries->search({ branchcode => { '!=' => $renegade_library->branchcode } }); } ); |
382 |
my $mock_item = Test::MockModule->new('Koha::Item'); |
384 |
my $mock_item = Test::MockModule->new('Koha::Item'); |
383 |
$mock_item->mock( 'pickup_locations', |
385 |
$mock_item->mock( 'pickup_locations', |
384 |
sub { return Koha::Libraries->search } ); |
386 |
sub { return Koha::Libraries->search({ branchcode => { '!=' => $renegade_library->branchcode } }) } ); |
385 |
|
387 |
|
386 |
my $can_item_be_reserved_result; |
388 |
my $can_item_be_reserved_result; |
387 |
my $mock_reserves = Test::MockModule->new('C4::Reserves'); |
389 |
my $mock_reserves = Test::MockModule->new('C4::Reserves'); |
Lines 433-438
subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub {
Link Here
|
433 |
{ 'x-koha-override' => 'any' } => json => $post_data ) |
435 |
{ 'x-koha-override' => 'any' } => json => $post_data ) |
434 |
->status_is(201); |
436 |
->status_is(201); |
435 |
|
437 |
|
|
|
438 |
# Test pickup locations can be overridden |
439 |
$post_data->{pickup_library_id} = $renegade_library->branchcode; |
440 |
|
441 |
$t->post_ok( "//$userid:$password@/api/v1/holds" => json => $post_data ) |
442 |
->status_is(400); |
443 |
|
444 |
$t->post_ok( "//$userid:$password@/api/v1/holds" => |
445 |
{ 'x-koha-override' => 'any' } => json => $post_data ) |
446 |
->status_is(201); |
447 |
|
436 |
$schema->storage->txn_rollback; |
448 |
$schema->storage->txn_rollback; |
437 |
}; |
449 |
}; |
438 |
|
450 |
|
439 |
- |
|
|