|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 57; |
20 |
use Test::More tests => 66; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 183-201
$t->request_ok($tx)
Link Here
|
| 183 |
->status_is(403) |
183 |
->status_is(403) |
| 184 |
->json_is({ error => "You don't have the required permission" }); |
184 |
->json_is({ error => "You don't have the required permission" }); |
| 185 |
|
185 |
|
|
|
186 |
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue2->issue_id . "/renewability"); |
| 187 |
$tx->req->cookies({name => 'CGISESSID', value => $borrower_session->id}); |
| 188 |
$t->request_ok($tx) |
| 189 |
->status_is(403) |
| 190 |
->json_is({ error => "You don't have the required permission" }); |
| 191 |
|
| 186 |
t::lib::Mocks::mock_preference( "OpacRenewalAllowed", 1 ); |
192 |
t::lib::Mocks::mock_preference( "OpacRenewalAllowed", 1 ); |
|
|
193 |
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue2->issue_id . "/renewability"); |
| 194 |
$tx->req->cookies({name => 'CGISESSID', value => $borrower_session->id}); |
| 195 |
$t->request_ok($tx) |
| 196 |
->status_is(200) |
| 197 |
->json_is({}); |
| 198 |
|
| 187 |
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue2->issue_id); |
199 |
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue2->issue_id); |
| 188 |
$tx->req->cookies({name => 'CGISESSID', value => $borrower_session->id}); |
200 |
$tx->req->cookies({name => 'CGISESSID', value => $borrower_session->id}); |
| 189 |
$t->request_ok($tx) |
201 |
$t->request_ok($tx) |
| 190 |
->status_is(200) |
202 |
->status_is(200) |
| 191 |
->json_is('/date_due' => $expected_datedue->ymd . ' ' . $expected_datedue->hms); |
203 |
->json_is('/date_due' => $expected_datedue->ymd . ' ' . $expected_datedue->hms); |
| 192 |
|
204 |
|
|
|
205 |
|
| 193 |
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue1->issue_id); |
206 |
$tx = $t->ua->build_tx(PUT => "/api/v1/checkouts/" . $issue1->issue_id); |
| 194 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
207 |
$tx->req->cookies({name => 'CGISESSID', value => $session->id}); |
| 195 |
$t->request_ok($tx) |
208 |
$t->request_ok($tx) |
| 196 |
->status_is(403) |
209 |
->status_is(403) |
| 197 |
->json_is({ error => 'Renewal not authorized (too_many)' }); |
210 |
->json_is({ error => 'Renewal not authorized (too_many)' }); |
| 198 |
|
211 |
|
|
|
212 |
$tx = $t->ua->build_tx(GET => "/api/v1/checkouts/" . $issue2->issue_id . "/renewability"); |
| 213 |
$tx->req->cookies({name => 'CGISESSID', value => $borrower_session->id}); |
| 214 |
$t->request_ok($tx) |
| 215 |
->status_is(403) |
| 216 |
->json_is({ error => 'Renewal not authorized (too_many)' }); |
| 217 |
|
| 199 |
sub create_biblio { |
218 |
sub create_biblio { |
| 200 |
my ($title) = @_; |
219 |
my ($title) = @_; |
| 201 |
|
220 |
|
| 202 |
- |
|
|