|
Lines 83-89
subtest 'list() tests' => sub {
Link Here
|
| 83 |
|
83 |
|
| 84 |
subtest 'librarian access tests' => sub { |
84 |
subtest 'librarian access tests' => sub { |
| 85 |
|
85 |
|
| 86 |
plan tests => 15; |
86 |
plan tests => 16; |
| 87 |
|
87 |
|
| 88 |
$schema->storage->txn_begin; |
88 |
$schema->storage->txn_begin; |
| 89 |
|
89 |
|
|
Lines 210-215
subtest 'list() tests' => sub {
Link Here
|
| 210 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' ); |
210 |
->json_is( '/0/patron_id' => $patron->id, 'Filtering by date-time works' ); |
| 211 |
}; |
211 |
}; |
| 212 |
|
212 |
|
|
|
213 |
subtest 'BorrowersViewLog' => sub { |
| 214 |
plan tests => 6; |
| 215 |
|
| 216 |
t::lib::Mocks::mock_preference( 'BorrowersViewLog', 1 ); |
| 217 |
|
| 218 |
$t->get_ok("//$userid:$password@/api/v1/patrons")->status_is(200); |
| 219 |
|
| 220 |
my $count = Koha::ActionLogs->search({ |
| 221 |
module => 'MEMBERS', |
| 222 |
action => 'VIEW', |
| 223 |
user => $librarian->borrowernumber, |
| 224 |
interface => 'api' |
| 225 |
})->count; |
| 226 |
|
| 227 |
ok($count>0, "BorrowersViewLog generated some view log entries"); |
| 228 |
|
| 229 |
t::lib::Mocks::mock_preference( 'BorrowersViewLog', 0 ); |
| 230 |
|
| 231 |
$t->get_ok("//$userid:$password@/api/v1/patrons")->status_is(200); |
| 232 |
|
| 233 |
my $off_count = Koha::ActionLogs->search({ |
| 234 |
module => 'MEMBERS', |
| 235 |
action => 'VIEW', |
| 236 |
user => $librarian->borrowernumber, |
| 237 |
interface => 'api' |
| 238 |
})->count; |
| 239 |
|
| 240 |
is($off_count, $count, "BorrowersViewLog does not generate log entries when disabled"); |
| 241 |
}; |
| 242 |
|
| 213 |
$schema->storage->txn_rollback; |
243 |
$schema->storage->txn_rollback; |
| 214 |
}; |
244 |
}; |
| 215 |
|
245 |
|
|
Lines 277-283
subtest 'get() tests' => sub {
Link Here
|
| 277 |
|
307 |
|
| 278 |
subtest 'librarian access tests' => sub { |
308 |
subtest 'librarian access tests' => sub { |
| 279 |
|
309 |
|
| 280 |
plan tests => 8; |
310 |
plan tests => 9; |
| 281 |
|
311 |
|
| 282 |
$schema->storage->txn_begin; |
312 |
$schema->storage->txn_begin; |
| 283 |
|
313 |
|
|
Lines 325-330
subtest 'get() tests' => sub {
Link Here
|
| 325 |
->json_is( '/patron_id' => $patron->id )->json_is( '/category_id' => $patron->categorycode ) |
355 |
->json_is( '/patron_id' => $patron->id )->json_is( '/category_id' => $patron->categorycode ) |
| 326 |
->json_is( '/surname' => $patron->surname )->json_is( '/patron_card_lost' => Mojo::JSON->false ); |
356 |
->json_is( '/surname' => $patron->surname )->json_is( '/patron_card_lost' => Mojo::JSON->false ); |
| 327 |
|
357 |
|
|
|
358 |
subtest 'BorrowersViewLog' => sub { |
| 359 |
plan tests => 6; |
| 360 |
|
| 361 |
t::lib::Mocks::mock_preference( 'BorrowersViewLog', 1 ); |
| 362 |
|
| 363 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id)->status_is(200); |
| 364 |
|
| 365 |
my $count = Koha::ActionLogs->search({ |
| 366 |
module => 'MEMBERS', |
| 367 |
action => 'VIEW', |
| 368 |
user => $librarian->borrowernumber, |
| 369 |
object => $patron->id, |
| 370 |
interface => 'api' |
| 371 |
})->count; |
| 372 |
|
| 373 |
ok($count>0, "BorrowersViewLog generated some view log entries for this patron"); |
| 374 |
|
| 375 |
t::lib::Mocks::mock_preference( 'BorrowersViewLog', 0 ); |
| 376 |
|
| 377 |
$t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron->id)->status_is(200); |
| 378 |
|
| 379 |
my $off_count = Koha::ActionLogs->search({ |
| 380 |
module => 'MEMBERS', |
| 381 |
action => 'VIEW', |
| 382 |
user => $librarian->borrowernumber, |
| 383 |
object => $patron->id, |
| 384 |
interface => 'api' |
| 385 |
})->count; |
| 386 |
|
| 387 |
is($off_count, $count, "BorrowersViewLog does not generate log entries when disabled"); |
| 388 |
}; |
| 389 |
|
| 328 |
$schema->storage->txn_rollback; |
390 |
$schema->storage->txn_rollback; |
| 329 |
}; |
391 |
}; |
| 330 |
|
392 |
|
| 331 |
- |
|
|