Lines 223-237
subtest 'add() tests' => sub {
Link Here
|
223 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
223 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
224 |
my $unauth_userid = $patron->userid; |
224 |
my $unauth_userid = $patron->userid; |
225 |
|
225 |
|
226 |
my $biblio = $builder->build_sample_biblio; |
226 |
my $biblio = $builder->build_sample_biblio; |
227 |
my $item1 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); |
227 |
my $item1 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); |
228 |
my $item2 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); |
228 |
my $item2 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); |
229 |
my $booking = { |
229 |
my $pickup_library = $builder->build_object( { class => 'Koha::Libraries' } ); |
230 |
biblio_id => $biblio->id, |
230 |
my $booking = { |
231 |
item_id => undef, |
231 |
biblio_id => $biblio->id, |
232 |
patron_id => $patron->id, |
232 |
item_id => undef, |
233 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
233 |
pickup_library_id => $pickup_library->branchcode, |
234 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
234 |
patron_id => $patron->id, |
|
|
235 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
236 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
235 |
}; |
237 |
}; |
236 |
|
238 |
|
237 |
# Unauthorized attempt to write |
239 |
# Unauthorized attempt to write |
Lines 314-328
subtest 'update() tests' => sub {
Link Here
|
314 |
"//$unauth_userid:$password@/api/v1/bookings/$booking_id" => json => { name => 'New unauthorized name change' } |
316 |
"//$unauth_userid:$password@/api/v1/bookings/$booking_id" => json => { name => 'New unauthorized name change' } |
315 |
)->status_is(403); |
317 |
)->status_is(403); |
316 |
|
318 |
|
317 |
my $biblio = $builder->build_sample_biblio; |
319 |
my $biblio = $builder->build_sample_biblio; |
318 |
my $item = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); |
320 |
my $item = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); |
|
|
321 |
my $pickup_library = $builder->build_object( { class => 'Koha::Libraries' } ); |
319 |
|
322 |
|
320 |
# Attempt partial update on a PUT |
323 |
# Attempt partial update on a PUT |
321 |
my $booking_with_missing_field = { |
324 |
my $booking_with_missing_field = { |
322 |
item_id => undef, |
325 |
item_id => undef, |
323 |
patron_id => $patron->id, |
326 |
patron_id => $patron->id, |
324 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
327 |
pickup_library_id => $pickup_library->branchcode, |
325 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
328 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
|
|
329 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
326 |
}; |
330 |
}; |
327 |
|
331 |
|
328 |
$t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_missing_field ) |
332 |
$t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_missing_field ) |
Lines 330-340
subtest 'update() tests' => sub {
Link Here
|
330 |
|
334 |
|
331 |
# Full object update on PUT |
335 |
# Full object update on PUT |
332 |
my $booking_with_updated_field = { |
336 |
my $booking_with_updated_field = { |
333 |
biblio_id => $biblio->id, |
337 |
biblio_id => $biblio->id, |
334 |
item_id => undef, |
338 |
item_id => undef, |
335 |
patron_id => $patron->id, |
339 |
pickup_library_id => $pickup_library->branchcode, |
336 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
340 |
patron_id => $patron->id, |
337 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
341 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
|
|
342 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
338 |
}; |
343 |
}; |
339 |
|
344 |
|
340 |
$t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_updated_field ) |
345 |
$t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_updated_field ) |
Lines 342-353
subtest 'update() tests' => sub {
Link Here
|
342 |
|
347 |
|
343 |
# Authorized attempt to write invalid data |
348 |
# Authorized attempt to write invalid data |
344 |
my $booking_with_invalid_field = { |
349 |
my $booking_with_invalid_field = { |
345 |
blah => "Booking Blah", |
350 |
blah => "Booking Blah", |
346 |
biblio_id => $biblio->id, |
351 |
biblio_id => $biblio->id, |
347 |
item_id => undef, |
352 |
item_id => undef, |
348 |
patron_id => $patron->id, |
353 |
pickup_library_id => $pickup_library->branchcode, |
349 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
354 |
patron_id => $patron->id, |
350 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
355 |
start_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 2 ) } ), |
|
|
356 |
end_date => output_pref( { dateformat => "rfc3339", dt => dt_from_string->add( days => 6 ) } ), |
351 |
}; |
357 |
}; |
352 |
|
358 |
|
353 |
$t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_invalid_field ) |
359 |
$t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_invalid_field ) |
354 |
- |
|
|