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

(-)a/Koha/REST/V1/Holds.pm (-3 / +3 lines)
Lines 243-251 sub edit { Link Here
243
243
244
    my $body = $c->req->json;
244
    my $body = $c->req->json;
245
245
246
    my $pickup_library_id = $body->{pickup_library_id};
246
    my $pickup_library_id = $body->{pickup_library_id} // $hold->branchcode;
247
    my $priority          = $body->{priority};
247
    my $priority          = $body->{priority} // $hold->priority;
248
    my $suspended_until   = $body->{suspended_until};
248
    my $suspended_until   = $body->{suspended_until} // $hold->suspend_until;
249
249
250
    if ($suspended_until) {
250
    if ($suspended_until) {
251
        $suspended_until = output_pref(dt_from_string($suspended_until, 'rfc3339'));
251
        $suspended_until = output_pref(dt_from_string($suspended_until, 'rfc3339'));
(-)a/t/db_dependent/api/v1/holds.t (-3 / +15 lines)
Lines 47-52 my $t = Test::Mojo->new('Koha::REST::V1'); Link Here
47
47
48
my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
48
my $categorycode = $builder->build({ source => 'Category' })->{categorycode};
49
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
49
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
50
my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode};
50
my $itemtype = $builder->build({ source => 'Itemtype' })->{itemtype};
51
my $itemtype = $builder->build({ source => 'Itemtype' })->{itemtype};
51
52
52
# Generic password for everyone
53
# Generic password for everyone
Lines 163-168 my $put_data = { Link Here
163
    priority => 2,
164
    priority => 2,
164
    suspended_until => output_pref({ dt => $suspended_until, dateformat => 'rfc3339' }),
165
    suspended_until => output_pref({ dt => $suspended_until, dateformat => 'rfc3339' }),
165
};
166
};
167
my $put_data2 = {
168
    pickup_library_id => $branchcode2
169
};
166
170
167
subtest "Test endpoints without authentication" => sub {
171
subtest "Test endpoints without authentication" => sub {
168
    plan tests => 8;
172
    plan tests => 8;
Lines 198-204 subtest "Test endpoints without permission" => sub { Link Here
198
202
199
subtest "Test endpoints with permission" => sub {
203
subtest "Test endpoints with permission" => sub {
200
204
201
    plan tests => 44;
205
    plan tests => 51;
202
206
203
    $t->get_ok( "//$userid_1:$password@/api/v1/holds" )
207
    $t->get_ok( "//$userid_1:$password@/api/v1/holds" )
204
      ->status_is(200)
208
      ->status_is(200)
Lines 219-225 subtest "Test endpoints with permission" => sub { Link Here
219
      ->status_is(200)
223
      ->status_is(200)
220
      ->json_is( '/hold_id', $reserve_id )
224
      ->json_is( '/hold_id', $reserve_id )
221
      ->json_is( '/suspended_until', $expected_suspended_until )
225
      ->json_is( '/suspended_until', $expected_suspended_until )
222
      ->json_is( '/priority', 2 );
226
      ->json_is( '/priority', 2 )
227
      ->json_is( '/pickup_library_id', $branchcode );
228
229
    # Change only pickup library, everything else should remain
230
    $t->put_ok( "//$userid_1:$password@/api/v1/holds/$reserve_id" => json => $put_data2 )
231
      ->status_is(200)
232
      ->json_is( '/hold_id', $reserve_id )
233
      ->json_is( '/suspended_until', $expected_suspended_until )
234
      ->json_is( '/priority', 2 )
235
      ->json_is( '/pickup_library_id', $branchcode2 );
223
236
224
    $t->delete_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id" )
237
    $t->delete_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id" )
225
      ->status_is(200);
238
      ->status_is(200);
226
- 

Return to bug 24680