View | Details | Raw Unified | Return to bug 27797
Collapse All | Expand All

(-)a/Koha/REST/V1/Holds.pm (-1 / +1 lines)
Lines 172-178 sub add { Link Here
172
        }
172
        }
173
173
174
        my $overrides = $c->stash('koha.overrides');
174
        my $overrides = $c->stash('koha.overrides');
175
        my $can_override = $overrides->{any} and C4::Context->preference('AllowHoldPolicyOverride');
175
        my $can_override = $overrides->{any} && C4::Context->preference('AllowHoldPolicyOverride');
176
176
177
        unless ( $can_override || $can_place_hold->{status} eq 'OK' ) {
177
        unless ( $can_override || $can_place_hold->{status} eq 'OK' ) {
178
            return $c->render(
178
            return $c->render(
(-)a/t/db_dependent/api/v1/holds.t (-2 / +12 lines)
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 => 8;
361
    plan tests => 12;
362
362
363
    $schema->storage->txn_begin;
363
    $schema->storage->txn_begin;
364
364
Lines 407-412 subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub { Link Here
407
      ->status_is(403)
407
      ->status_is(403)
408
      ->json_is( '/error' => "Hold cannot be placed. Reason: ageRestricted" );
408
      ->json_is( '/error' => "Hold cannot be placed. Reason: ageRestricted" );
409
409
410
    # x-koha-override doesn't override if AllowHoldPolicyOverride not set
411
    $t->post_ok( "//$userid:$password@/api/v1/holds" =>
412
          { 'x-koha-override' => 'any' } => json => $post_data )
413
      ->status_is(403);
414
410
    t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 );
415
    t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 );
411
416
412
    $can_item_be_reserved_result = { status => 'pickupNotInHoldGroup' };
417
    $can_item_be_reserved_result = { status => 'pickupNotInHoldGroup' };
Lines 416-423 subtest 'x-koha-override and AllowHoldPolicyOverride tests' => sub { Link Here
416
      ->json_is(
421
      ->json_is(
417
        '/error' => "Hold cannot be placed. Reason: pickupNotInHoldGroup" );
422
        '/error' => "Hold cannot be placed. Reason: pickupNotInHoldGroup" );
418
423
424
    # x-koha-override overrides the status
425
    $t->post_ok( "//$userid:$password@/api/v1/holds" =>
426
          { 'x-koha-override' => 'any' } => json => $post_data )
427
      ->status_is(201);
428
419
    $can_item_be_reserved_result = { status => 'OK' };
429
    $can_item_be_reserved_result = { status => 'OK' };
420
430
431
    # x-koha-override works when status not need override
421
    $t->post_ok( "//$userid:$password@/api/v1/holds" =>
432
    $t->post_ok( "//$userid:$password@/api/v1/holds" =>
422
          { 'x-koha-override' => 'any' } => json => $post_data )
433
          { 'x-koha-override' => 'any' } => json => $post_data )
423
      ->status_is(201);
434
      ->status_is(201);
424
- 

Return to bug 27797