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

(-)a/Koha/REST/V1/Hold.pm (-1 / +7 lines)
Lines 141-150 sub edit { Link Here
141
        reserve_id => $reserve_id,
141
        reserve_id => $reserve_id,
142
        branchcode => $branchcode,
142
        branchcode => $branchcode,
143
        rank => $priority,
143
        rank => $priority,
144
        suspend_until => $suspend_until,
145
    };
144
    };
146
145
147
    C4::Reserves::ModReserve($params);
146
    C4::Reserves::ModReserve($params);
147
148
    my $borrowernumber = $reserve->{borrowernumber};
149
    if (C4::Reserves::CanReserveBeCanceledFromOpac($reserve_id, $borrowernumber)){
150
        C4::Reserves::ToggleSuspend( $reserve_id, $suspend_until ) if
151
            (defined $body->{suspend} || $suspend_until);
152
    }
153
148
    $reserve = Koha::Holds->find($reserve_id);
154
    $reserve = Koha::Holds->find($reserve_id);
149
155
150
    return $c->render( status => 200, openapi => $reserve );
156
    return $c->render( status => 200, openapi => $reserve );
(-)a/api/v1/swagger/paths/holds.json (+4 lines)
Lines 273-278 Link Here
273
                "description": "Pickup location",
273
                "description": "Pickup location",
274
                "type": "string"
274
                "type": "string"
275
              },
275
              },
276
              "suspend": {
277
                "description": "Suspend hold",
278
                "type": "boolean"
279
              },
276
              "suspend_until": {
280
              "suspend_until": {
277
                "description": "Suspend until",
281
                "description": "Suspend until",
278
                "type": "string",
282
                "type": "string",
(-)a/t/db_dependent/api/v1/holds.t (-3 / +22 lines)
Lines 186-192 subtest "Test endpoints without permission" => sub { Link Here
186
      ->status_is(403);
186
      ->status_is(403);
187
};
187
};
188
subtest "Test endpoints without permission, but accessing own object" => sub {
188
subtest "Test endpoints without permission, but accessing own object" => sub {
189
    plan tests => 15;
189
    plan tests => 25;
190
190
191
    my $borrno_tmp = $post_data->{'borrowernumber'};
191
    my $borrno_tmp = $post_data->{'borrowernumber'};
192
    $post_data->{'borrowernumber'} = int $nopermission->{'borrowernumber'};
192
    $post_data->{'borrowernumber'} = int $nopermission->{'borrowernumber'};
Lines 210-220 subtest "Test endpoints without permission, but accessing own object" => sub { Link Here
210
    my $reserve_id3 = Koha::Holds->find({ borrowernumber => $nopermission->{borrowernumber} })->reserve_id;
210
    my $reserve_id3 = Koha::Holds->find({ borrowernumber => $nopermission->{borrowernumber} })->reserve_id;
211
    $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => $put_data);
211
    $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => $put_data);
212
    $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id});
212
    $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id});
213
    $t->request_ok($tx) # create hold to myself
213
    $t->request_ok($tx)
214
      ->status_is(200)
214
      ->status_is(200)
215
      ->json_is('/reserve_id', $reserve_id3)
215
      ->json_is('/reserve_id', $reserve_id3)
216
      ->json_is('/suspend_until', $suspend_until . ' 00:00:00')
216
      ->json_is('/suspend_until', $suspend_until . ' 00:00:00')
217
      ->json_is('/priority', 2);
217
      ->json_is('/priority', 2);
218
219
    $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => {
220
        suspend => Mojo::JSON->false
221
    });
222
    $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id});
223
    $t->request_ok($tx)
224
      ->status_is(200)
225
      ->json_is('/reserve_id', $reserve_id3)
226
      ->json_is('/suspend', Mojo::JSON->false)
227
      ->json_is('/suspend_until', undef);
228
229
    $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => {
230
        suspend_until => $suspend_until
231
    });
232
    $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id});
233
    $t->request_ok($tx)
234
      ->status_is(200)
235
      ->json_is('/reserve_id', $reserve_id3)
236
      ->json_is('/suspend', Mojo::JSON->true)
237
      ->json_like('/suspend_until', qr/^$suspend_until/);
218
};
238
};
219
239
220
subtest "Test endpoints with permission" => sub {
240
subtest "Test endpoints with permission" => sub {
221
- 

Return to bug 19072