Lines 892-898
subtest 'pickup_locations() tests' => sub {
Link Here
|
892 |
|
892 |
|
893 |
subtest 'edit() tests' => sub { |
893 |
subtest 'edit() tests' => sub { |
894 |
|
894 |
|
895 |
plan tests => 20; |
895 |
plan tests => 37; |
896 |
|
896 |
|
897 |
$schema->storage->txn_begin; |
897 |
$schema->storage->txn_begin; |
898 |
|
898 |
|
Lines 963-968
subtest 'edit() tests' => sub {
Link Here
|
963 |
->status_is(400) |
963 |
->status_is(400) |
964 |
->json_is({ error => 'The supplied pickup location is not valid' }); |
964 |
->json_is({ error => 'The supplied pickup location is not valid' }); |
965 |
|
965 |
|
|
|
966 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" |
967 |
. $biblio_hold->id |
968 |
=> json => $biblio_hold_data ) |
969 |
->status_is(400) |
970 |
->json_is({ error => 'The supplied pickup location is not valid' }); |
971 |
|
966 |
$biblio_hold->discard_changes; |
972 |
$biblio_hold->discard_changes; |
967 |
is( $biblio_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); |
973 |
is( $biblio_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); |
968 |
|
974 |
|
Lines 972-977
subtest 'edit() tests' => sub {
Link Here
|
972 |
->status_is(200) |
978 |
->status_is(200) |
973 |
->json_has( '/pickup_library_id' => $library_1->id ); |
979 |
->json_has( '/pickup_library_id' => $library_1->id ); |
974 |
|
980 |
|
|
|
981 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id |
982 |
=> { 'x-koha-override' => 'any' } |
983 |
=> json => $biblio_hold_data ) |
984 |
->status_is(200) |
985 |
->json_has( '/pickup_library_id' => $library_1->id ); |
986 |
|
975 |
$biblio_hold_data->{pickup_library_id} = $library_2->branchcode; |
987 |
$biblio_hold_data->{pickup_library_id} = $library_2->branchcode; |
976 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" |
988 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" |
977 |
. $biblio_hold->id |
989 |
. $biblio_hold->id |
Lines 981-986
subtest 'edit() tests' => sub {
Link Here
|
981 |
$biblio_hold->discard_changes; |
993 |
$biblio_hold->discard_changes; |
982 |
is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); |
994 |
is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); |
983 |
|
995 |
|
|
|
996 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" |
997 |
. $biblio_hold->id |
998 |
=> json => $biblio_hold_data ) |
999 |
->status_is(200); |
1000 |
|
1001 |
$biblio_hold->discard_changes; |
1002 |
is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); |
1003 |
|
984 |
# Test item-level holds |
1004 |
# Test item-level holds |
985 |
my $item_hold = $builder->build_object( |
1005 |
my $item_hold = $builder->build_object( |
986 |
{ |
1006 |
{ |
Lines 1006-1011
subtest 'edit() tests' => sub {
Link Here
|
1006 |
->status_is(400) |
1026 |
->status_is(400) |
1007 |
->json_is({ error => 'The supplied pickup location is not valid' }); |
1027 |
->json_is({ error => 'The supplied pickup location is not valid' }); |
1008 |
|
1028 |
|
|
|
1029 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" |
1030 |
. $item_hold->id |
1031 |
=> json => $item_hold_data ) |
1032 |
->status_is(400) |
1033 |
->json_is({ error => 'The supplied pickup location is not valid' }); |
1034 |
|
1009 |
$item_hold->discard_changes; |
1035 |
$item_hold->discard_changes; |
1010 |
is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); |
1036 |
is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); |
1011 |
|
1037 |
|
Lines 1015-1026
subtest 'edit() tests' => sub {
Link Here
|
1015 |
->status_is(200) |
1041 |
->status_is(200) |
1016 |
->json_has( '/pickup_library_id' => $library_1->id ); |
1042 |
->json_has( '/pickup_library_id' => $library_1->id ); |
1017 |
|
1043 |
|
|
|
1044 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id |
1045 |
=> { 'x-koha-override' => 'any' } |
1046 |
=> json => $item_hold_data ) |
1047 |
->status_is(200) |
1048 |
->json_has( '/pickup_library_id' => $library_1->id ); |
1049 |
|
1018 |
$item_hold_data->{pickup_library_id} = $library_2->branchcode; |
1050 |
$item_hold_data->{pickup_library_id} = $library_2->branchcode; |
1019 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" |
1051 |
$t->patch_ok( "//$userid:$password@/api/v1/holds/" |
1020 |
. $item_hold->id |
1052 |
. $item_hold->id |
1021 |
=> json => $item_hold_data ) |
1053 |
=> json => $item_hold_data ) |
1022 |
->status_is(200); |
1054 |
->status_is(200); |
1023 |
|
1055 |
|
|
|
1056 |
$t->put_ok( "//$userid:$password@/api/v1/holds/" |
1057 |
. $item_hold->id |
1058 |
=> json => $item_hold_data ) |
1059 |
->status_is(200); |
1060 |
|
1024 |
$item_hold->discard_changes; |
1061 |
$item_hold->discard_changes; |
1025 |
is( $item_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); |
1062 |
is( $item_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); |
1026 |
|
1063 |
|
1027 |
- |
|
|