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 387-392 Link Here
387
      }
387
      }
388
    }
388
    }
389
  },
389
  },
390
  "/holds/{hold_id}/priority": {
391
    "put": {
392
      "x-mojo-to": "Holds#update_priority",
393
      "operationId": "updateHoldPriority",
394
      "tags": [
395
        "biblios",
396
        "holds"
397
      ],
398
      "parameters": [
399
        {
400
          "$ref": "../parameters.json#/hold_id_pp"
401
        },
402
        {
403
          "name": "body",
404
          "in": "body",
405
          "description": "An integer representing the new priority to be set for the hold",
406
          "required": true,
407
          "schema": {
408
            "type": "integer"
409
          }
410
        }
411
      ],
412
      "produces": [
413
        "application/json"
414
      ],
415
      "responses": {
416
        "200": {
417
          "description": "The new priority value for the hold",
418
          "schema": {
419
            "type": "integer"
420
          }
421
        },
422
        "401": {
423
          "description": "Authentication required",
424
          "schema": {
425
            "$ref": "../definitions.json#/error"
426
          }
427
        },
428
        "403": {
429
          "description": "Access forbidden",
430
          "schema": {
431
            "$ref": "../definitions.json#/error"
432
          }
433
        },
434
        "404": {
435
          "description": "Biblio not found",
436
          "schema": {
437
            "$ref": "../definitions.json#/error"
438
          }
439
        },
440
        "409": {
441
          "description": "Unable to perform action on biblio",
442
          "schema": {
443
            "$ref": "../definitions.json#/error"
444
          }
445
        },
446
        "500": {
447
          "description": "Internal error",
448
          "schema": {
449
            "$ref": "../definitions.json#/error"
450
          }
451
        },
452
        "503": {
453
          "description": "Under maintenance",
454
          "schema": {
455
            "$ref": "../definitions.json#/error"
456
          }
457
        }
458
      },
459
      "x-koha-authorization": {
460
        "permissions": {
461
          "reserveforothers": "modify_holds_priority"
462
        }
463
      }
464
    }
465
  },
390
  "/holds/{hold_id}/suspension": {
466
  "/holds/{hold_id}/suspension": {
391
    "post": {
467
    "post": {
392
      "x-mojo-to": "Holds#suspend",
468
      "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