|
Lines 40-46
subtest 'cancel() tests' => sub {
Link Here
|
| 40 |
my $authorized_patron = $builder->build_object( |
40 |
my $authorized_patron = $builder->build_object( |
| 41 |
{ |
41 |
{ |
| 42 |
class => 'Koha::Patrons', |
42 |
class => 'Koha::Patrons', |
| 43 |
value => { flags => 1 } |
43 |
value => { flags => 2 ** 1 } # circulate flag = 1 |
| 44 |
} |
44 |
} |
| 45 |
); |
45 |
); |
| 46 |
my $password = 'thePassword123'; |
46 |
my $password = 'thePassword123'; |
|
Lines 80-86
subtest 'cancel() tests' => sub {
Link Here
|
| 80 |
|
80 |
|
| 81 |
subtest 'patron_cancel() tests' => sub { |
81 |
subtest 'patron_cancel() tests' => sub { |
| 82 |
|
82 |
|
| 83 |
plan tests => 12; |
83 |
plan tests => 14; |
| 84 |
|
84 |
|
| 85 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
85 |
t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); |
| 86 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
86 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
|
Lines 90-96
subtest 'patron_cancel() tests' => sub {
Link Here
|
| 90 |
my $patron = $builder->build_object( |
90 |
my $patron = $builder->build_object( |
| 91 |
{ |
91 |
{ |
| 92 |
class => 'Koha::Patrons', |
92 |
class => 'Koha::Patrons', |
| 93 |
value => { privacy_guarantor_checkouts => 0 } |
93 |
value => { flags => 0 } |
| 94 |
} |
94 |
} |
| 95 |
); |
95 |
); |
| 96 |
my $password = 'thePassword123'; |
96 |
my $password = 'thePassword123'; |
|
Lines 102-116
subtest 'patron_cancel() tests' => sub {
Link Here
|
| 102 |
my $deleted_article_request_id = $deleted_article_request->id; |
102 |
my $deleted_article_request_id = $deleted_article_request->id; |
| 103 |
$deleted_article_request->delete; |
103 |
$deleted_article_request->delete; |
| 104 |
|
104 |
|
|
|
105 |
# delete non existent article request |
| 106 |
$t->delete_ok("//$userid:$password@/api/v1/public/patrons/$patron_id/article_requests/$deleted_article_request_id") |
| 107 |
->status_is(404) |
| 108 |
->json_is( { error => "Article request not found" } ); |
| 109 |
|
| 105 |
my $another_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
110 |
my $another_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 106 |
my $another_patron_id = $another_patron->id; |
111 |
my $another_patron_id = $another_patron->id; |
| 107 |
|
112 |
|
| 108 |
$t->delete_ok("//$userid:$password@/api/v1/public/patrons/$another_patron_id/article_requests/$deleted_article_request_id") |
113 |
my $article_request_2 = $builder->build_object({ class => 'Koha::ArticleRequests', value => { borrowernumber => $another_patron_id } }); |
| 109 |
->status_is(403); |
|
|
| 110 |
|
114 |
|
| 111 |
$t->delete_ok("//$userid:$password@/api/v1/public/patrons/$patron_id/article_requests/$deleted_article_request_id") |
115 |
# delete another patron's request |
| 112 |
->status_is(404) |
116 |
$t->delete_ok("//$userid:$password@/api/v1/public/patrons/$another_patron_id/article_requests/" . $article_request_2->id) |
| 113 |
->json_is( { error => "Article request not found" } ); |
117 |
->status_is(403) |
|
|
118 |
->json_is( '/error' => 'Authorization failure. Missing required permission(s).' ); |
| 114 |
|
119 |
|
| 115 |
my $another_article_request = $builder->build_object( |
120 |
my $another_article_request = $builder->build_object( |
| 116 |
{ |
121 |
{ |
|
Lines 119-127
subtest 'patron_cancel() tests' => sub {
Link Here
|
| 119 |
} |
124 |
} |
| 120 |
); |
125 |
); |
| 121 |
|
126 |
|
| 122 |
$t->delete_ok("//$userid:$password@/api/v1/public/patrons/$patron_id/article_requests/$another_article_request") |
127 |
$t->delete_ok("//$userid:$password@/api/v1/public/patrons/$patron_id/article_requests/" . $another_article_request->id) |
| 123 |
->status_is(403); |
128 |
->status_is(404) |
| 124 |
|
129 |
->json_is( { error => 'Article request not found' } ); |
| 125 |
|
130 |
|
| 126 |
my $article_request = $builder->build_object( |
131 |
my $article_request = $builder->build_object( |
| 127 |
{ |
132 |
{ |
| 128 |
- |
|
|