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

(-)a/Koha/REST/V1/TransferLimits.pm (-3 / +3 lines)
Lines 72-78 sub add { Link Here
72
        if ( Koha::Item::Transfer::Limits->search( $transfer_limit->attributes_from_api($params) )->count == 0 ) {
72
        if ( Koha::Item::Transfer::Limits->search( $transfer_limit->attributes_from_api($params) )->count == 0 ) {
73
            $transfer_limit->store;
73
            $transfer_limit->store;
74
        } else {
74
        } else {
75
            Koha::Exceptions::TransferLimit::Duplicate->throw()
75
            Koha::Exceptions::TransferLimit::Duplicate->throw();
76
        }
76
        }
77
77
78
        return $c->render(
78
        return $c->render(
Lines 81-90 sub add { Link Here
81
        );
81
        );
82
    }
82
    }
83
    catch {
83
    catch {
84
        if ( blessed $_ && $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
84
        if ( blessed $_ && $_->isa('Koha::Exceptions::TransferLimit::Duplicate') ) {
85
            return $c->render(
85
            return $c->render(
86
                status  => 409,
86
                status  => 409,
87
                openapi => { error => $_->error, conflict => $_->duplicate_id }
87
                openapi => { error => "$_" }
88
            );
88
            );
89
        }
89
        }
90
90
(-)a/t/db_dependent/api/v1/transfer_limits.t (-2 / +9 lines)
Lines 62-68 subtest 'list() tests' => sub { Link Here
62
62
63
subtest 'add() tests' => sub {
63
subtest 'add() tests' => sub {
64
64
65
    plan tests => 8;
65
    plan tests => 11;
66
66
67
    $schema->storage->txn_begin;
67
    $schema->storage->txn_begin;
68
68
Lines 109-114 subtest 'add() tests' => sub { Link Here
109
      ->status_is( 201, 'SWAGGER3.2.1' )
109
      ->status_is( 201, 'SWAGGER3.2.1' )
110
      ->json_has( '' => $limit_hashref, 'SWAGGER3.3.1' );
110
      ->json_has( '' => $limit_hashref, 'SWAGGER3.3.1' );
111
111
112
    $t->post_ok( "//$auth_userid:$password@/api/v1/transfer_limits" => json => $limit_hashref )
113
      ->status_is( 409, 'Conflict creating the resource' )
114
      ->json_is(
115
        {
116
            error => "[A transfer limit with the given parameters already exists!]"
117
        }
118
      );
119
112
    $schema->storage->txn_rollback;
120
    $schema->storage->txn_rollback;
113
};
121
};
114
122
115
- 

Return to bug 26633