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

(-)a/api/v1/swagger/paths.json (+3 lines)
Lines 35-40 Link Here
35
  "/holds/{hold_id}": {
35
  "/holds/{hold_id}": {
36
    "$ref": "paths/holds.json#/~1holds~1{hold_id}"
36
    "$ref": "paths/holds.json#/~1holds~1{hold_id}"
37
  },
37
  },
38
  "/holds/{hold_id}/priority": {
39
    "$ref": "paths/holds.json#/~1holds~1{hold_id}~1priority"
40
  },
38
  "/holds/{hold_id}/suspension": {
41
  "/holds/{hold_id}/suspension": {
39
    "$ref": "paths/holds.json#/~1holds~1{hold_id}~1suspension"
42
    "$ref": "paths/holds.json#/~1holds~1{hold_id}~1suspension"
40
  },
43
  },
(-)a/api/v1/swagger/paths/holds.json (+76 lines)
Lines 399-404 Link Here
399
      }
399
      }
400
    }
400
    }
401
  },
401
  },
402
  "/holds/{hold_id}/priority": {
403
    "put": {
404
      "x-mojo-to": "Holds#update_priority",
405
      "operationId": "updateHoldPriority",
406
      "tags": [
407
        "biblios",
408
        "holds"
409
      ],
410
      "parameters": [
411
        {
412
          "$ref": "../parameters.json#/hold_id_pp"
413
        },
414
        {
415
          "name": "body",
416
          "in": "body",
417
          "description": "An integer representing the new priority to be set for the hold",
418
          "required": true,
419
          "schema": {
420
            "type": "integer"
421
          }
422
        }
423
      ],
424
      "produces": [
425
        "application/json"
426
      ],
427
      "responses": {
428
        "200": {
429
          "description": "The new priority value for the hold",
430
          "schema": {
431
            "type": "integer"
432
          }
433
        },
434
        "401": {
435
          "description": "Authentication required",
436
          "schema": {
437
            "$ref": "../definitions.json#/error"
438
          }
439
        },
440
        "403": {
441
          "description": "Access forbidden",
442
          "schema": {
443
            "$ref": "../definitions.json#/error"
444
          }
445
        },
446
        "404": {
447
          "description": "Biblio not found",
448
          "schema": {
449
            "$ref": "../definitions.json#/error"
450
          }
451
        },
452
        "409": {
453
          "description": "Unable to perform action on biblio",
454
          "schema": {
455
            "$ref": "../definitions.json#/error"
456
          }
457
        },
458
        "500": {
459
          "description": "Internal error",
460
          "schema": {
461
            "$ref": "../definitions.json#/error"
462
          }
463
        },
464
        "503": {
465
          "description": "Under maintenance",
466
          "schema": {
467
            "$ref": "../definitions.json#/error"
468
          }
469
        }
470
      },
471
      "x-koha-authorization": {
472
        "permissions": {
473
          "reserveforothers": "modify_holds_priority"
474
        }
475
      }
476
    }
477
  },
402
  "/holds/{hold_id}/suspension": {
478
  "/holds/{hold_id}/suspension": {
403
    "post": {
479
    "post": {
404
      "x-mojo-to": "Holds#suspend",
480
      "x-mojo-to": "Holds#suspend",
(-)a/t/db_dependent/api/v1/holds.t (-2 / +87 lines)
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
- 

Return to bug 23517