|
Lines 58-68
subtest 'add() tests' => sub {
Link Here
|
| 58 |
$schema->storage->txn_rollback; |
58 |
$schema->storage->txn_rollback; |
| 59 |
|
59 |
|
| 60 |
subtest 'librarian access tests' => sub { |
60 |
subtest 'librarian access tests' => sub { |
| 61 |
plan tests => 8; |
61 |
plan tests => 9; |
| 62 |
|
62 |
|
| 63 |
$schema->storage->txn_begin; |
63 |
$schema->storage->txn_begin; |
| 64 |
|
64 |
|
| 65 |
my ($club_with_enrollments, $club_without_enrollments, $item, @enrollments) = create_test_data(); |
65 |
my ($club_with_enrollments, $club_without_enrollments, $item, @enrollments) = create_test_data(); |
|
|
66 |
my $club_with_enrollments_id = $club_with_enrollments->id; |
| 66 |
|
67 |
|
| 67 |
my ( undef, $session_id ) = create_user_and_session({ authorized => 1 }); |
68 |
my ( undef, $session_id ) = create_user_and_session({ authorized => 1 }); |
| 68 |
my $data = { |
69 |
my $data = { |
|
Lines 81-98
subtest 'add() tests' => sub {
Link Here
|
| 81 |
->status_is(201, 'Created Hold') |
82 |
->status_is(201, 'Created Hold') |
| 82 |
->json_has('/club_hold_id', 'got a club hold id') |
83 |
->json_has('/club_hold_id', 'got a club hold id') |
| 83 |
->json_is( '/club_id' => $club_with_enrollments->id) |
84 |
->json_is( '/club_id' => $club_with_enrollments->id) |
| 84 |
->json_is( '/biblio_id' => $item->biblionumber); |
85 |
->json_is( '/biblio_id' => $item->biblionumber) |
|
|
86 |
->header_like( |
| 87 |
Location => qr|^\/api\/v1\/clubs/$club_with_enrollments_id/holds|, |
| 88 |
'SWAGGER3.4.1' |
| 89 |
); |
| 85 |
|
90 |
|
| 86 |
$schema->storage->txn_rollback; |
91 |
$schema->storage->txn_rollback; |
| 87 |
}; |
92 |
}; |
| 88 |
}; |
93 |
}; |
| 89 |
|
94 |
|
| 90 |
subtest "default patron home" => sub { |
95 |
subtest "default patron home" => sub { |
| 91 |
plan tests => 8; |
96 |
plan tests => 9; |
| 92 |
|
97 |
|
| 93 |
$schema->storage->txn_begin; |
98 |
$schema->storage->txn_begin; |
| 94 |
|
99 |
|
| 95 |
my ($club_with_enrollments, $club_without_enrollments, $item, @enrollments) = create_test_data(); |
100 |
my ($club_with_enrollments, $club_without_enrollments, $item, @enrollments) = create_test_data(); |
|
|
101 |
my $club_with_enrollments_id = $club_with_enrollments->id; |
| 96 |
|
102 |
|
| 97 |
my ( undef, $session_id ) = create_user_and_session({ authorized => 1 }); |
103 |
my ( undef, $session_id ) = create_user_and_session({ authorized => 1 }); |
| 98 |
my $data = { |
104 |
my $data = { |
|
Lines 104-110
subtest "default patron home" => sub {
Link Here
|
| 104 |
my $tx = $t->ua->build_tx(POST => "/api/v1/clubs/".$club_with_enrollments->id."/holds" => json => $data); |
110 |
my $tx = $t->ua->build_tx(POST => "/api/v1/clubs/".$club_with_enrollments->id."/holds" => json => $data); |
| 105 |
$tx->req->cookies({ name => 'CGISESSID', value => $session_id }); |
111 |
$tx->req->cookies({ name => 'CGISESSID', value => $session_id }); |
| 106 |
$t->request_ok($tx) |
112 |
$t->request_ok($tx) |
| 107 |
->status_is(201, 'Created Hold'); |
113 |
->status_is(201, 'Created Hold') |
|
|
114 |
->header_like( |
| 115 |
Location => qr|^\/api\/v1\/clubs/$club_with_enrollments_id/holds|, |
| 116 |
'SWAGGER3.4.1' |
| 117 |
); |
| 108 |
|
118 |
|
| 109 |
my $json_response = decode_json $t->tx->res->content->get_body_chunk; |
119 |
my $json_response = decode_json $t->tx->res->content->get_body_chunk; |
| 110 |
|
120 |
|
|
Lines 197-200
sub create_test_data {
Link Here
|
| 197 |
$lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); |
207 |
$lib = $builder->build_object({ class => 'Koha::Libraries', value => {pickup_location => 1}}); |
| 198 |
my $item = $builder->build_sample_item({homebranch => $lib->branchcode}); |
208 |
my $item = $builder->build_sample_item({homebranch => $lib->branchcode}); |
| 199 |
return ( $club_with_enrollments, $club_without_enrollments, $item, [ $enrollment1, $enrollment2, $enrollment3, $enrollment4, $enrollment5, $enrollment6 ] ); |
209 |
return ( $club_with_enrollments, $club_without_enrollments, $item, [ $enrollment1, $enrollment2, $enrollment3, $enrollment4, $enrollment5, $enrollment6 ] ); |
| 200 |
} |
210 |
} |
| 201 |
- |
|
|