|
Lines 63-76
subtest 'start()' => sub {
Link Here
|
| 63 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
63 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 64 |
my $userid = $patron->userid; |
64 |
my $userid = $patron->userid; |
| 65 |
|
65 |
|
| 66 |
$t->get_ok("//$userid:$password@/api/v1/public/patrons/self_renewal")->status_is( 403, 'REST3.2.2' ) |
66 |
my $borrowernumber = $patron->borrowernumber; |
| 67 |
->json_is( { error => "You are not eligible for self-renewal" } ); |
67 |
|
|
|
68 |
$t->get_ok("//$userid:$password@/api/v1/public/patrons/$borrowernumber/self_renewal") |
| 69 |
->status_is( 403, 'REST3.2.2' )->json_is( { error => "You are not eligible for self-renewal" } ); |
| 68 |
|
70 |
|
| 69 |
$category->self_renewal_enabled(1)->store(); |
71 |
$category->self_renewal_enabled(1)->store(); |
| 70 |
|
72 |
|
| 71 |
t::lib::Mocks::mock_preference( 'OPACPatronDetails', 1 ); |
73 |
t::lib::Mocks::mock_preference( 'OPACPatronDetails', 1 ); |
| 72 |
|
74 |
|
| 73 |
$t->get_ok("//$userid:$password@/api/v1/public/patrons/self_renewal")->status_is( 200, 'REST3.2.2' )->json_is( |
75 |
$t->get_ok("//$userid:$password@/api/v1/public/patrons/$borrowernumber/self_renewal") |
|
|
76 |
->status_is( 200, 'REST3.2.2' )->json_is( |
| 74 |
{ |
77 |
{ |
| 75 |
verification_checks => [], |
78 |
verification_checks => [], |
| 76 |
self_renewal_settings => { |
79 |
self_renewal_settings => { |
|
Lines 78-84
subtest 'start()' => sub {
Link Here
|
| 78 |
opac_patron_details => 1 |
81 |
opac_patron_details => 1 |
| 79 |
} |
82 |
} |
| 80 |
} |
83 |
} |
| 81 |
); |
84 |
); |
| 82 |
|
85 |
|
| 83 |
my $attribute_type = $builder->build_object( |
86 |
my $attribute_type = $builder->build_object( |
| 84 |
{ |
87 |
{ |
|
Lines 111-117
subtest 'start()' => sub {
Link Here
|
| 111 |
} |
114 |
} |
| 112 |
} |
115 |
} |
| 113 |
); |
116 |
); |
| 114 |
$t->get_ok("//$userid:$password@/api/v1/public/patrons/self_renewal")->status_is( 200, 'REST3.2.2' )->json_is( |
117 |
$t->get_ok("//$userid:$password@/api/v1/public/patrons/$borrowernumber/self_renewal") |
|
|
118 |
->status_is( 200, 'REST3.2.2' )->json_is( |
| 115 |
{ |
119 |
{ |
| 116 |
verification_checks => [ $attribute_type->unblessed ], |
120 |
verification_checks => [ $attribute_type->unblessed ], |
| 117 |
self_renewal_settings => { |
121 |
self_renewal_settings => { |
|
Lines 119-125
subtest 'start()' => sub {
Link Here
|
| 119 |
opac_patron_details => 1 |
123 |
opac_patron_details => 1 |
| 120 |
} |
124 |
} |
| 121 |
} |
125 |
} |
| 122 |
); |
126 |
); |
| 123 |
|
127 |
|
| 124 |
$schema->storage->txn_rollback; |
128 |
$schema->storage->txn_rollback; |
| 125 |
}; |
129 |
}; |
|
Lines 155-161
subtest 'submit()' => sub {
Link Here
|
| 155 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
159 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 156 |
my $userid = $patron->userid; |
160 |
my $userid = $patron->userid; |
| 157 |
|
161 |
|
| 158 |
$t->post_ok( "//$userid:$password@/api/v1/public/patrons/self_renewal" => json => {} ) |
162 |
my $borrowernumber = $patron->borrowernumber; |
|
|
163 |
|
| 164 |
$t->post_ok( "//$userid:$password@/api/v1/public/patrons/$borrowernumber/self_renewal" => json => {} ) |
| 159 |
->status_is( 403, 'REST3.2.2' )->json_is( { error => "You are not eligible for self-renewal" } ); |
165 |
->status_is( 403, 'REST3.2.2' )->json_is( { error => "You are not eligible for self-renewal" } ); |
| 160 |
|
166 |
|
| 161 |
t::lib::Mocks::mock_preference( 'OPACPatronDetails', 1 ); |
167 |
t::lib::Mocks::mock_preference( 'OPACPatronDetails', 1 ); |
|
Lines 190-196
subtest 'submit()' => sub {
Link Here
|
| 190 |
); |
196 |
); |
| 191 |
|
197 |
|
| 192 |
my $counter = Koha::Notice::Messages->search( { borrowernumber => $patron->borrowernumber } )->count; |
198 |
my $counter = Koha::Notice::Messages->search( { borrowernumber => $patron->borrowernumber } )->count; |
| 193 |
$t->post_ok( "//$userid:$password@/api/v1/public/patrons/self_renewal" => json => {} ) |
199 |
$t->post_ok( "//$userid:$password@/api/v1/public/patrons/$borrowernumber/self_renewal" => json => {} ) |
| 194 |
->status_is( 201, 'REST3.2.2' ) |
200 |
->status_is( 201, 'REST3.2.2' ) |
| 195 |
->json_is( { expiry_date => $expiry_date->truncate( to => 'day' ), confirmation_sent => 1 } ); |
201 |
->json_is( { expiry_date => $expiry_date->truncate( to => 'day' ), confirmation_sent => 1 } ); |
| 196 |
is( |
202 |
is( |
|
Lines 203-209
subtest 'submit()' => sub {
Link Here
|
| 203 |
my $modification_data = { firstname => 'Newname' }; |
209 |
my $modification_data = { firstname => 'Newname' }; |
| 204 |
$patron->dateexpiry( dt_from_string() )->store(); |
210 |
$patron->dateexpiry( dt_from_string() )->store(); |
| 205 |
|
211 |
|
| 206 |
$t->post_ok( "//$userid:$password@/api/v1/public/patrons/self_renewal" => json => $modification_data ) |
212 |
$t->post_ok( |
|
|
213 |
"//$userid:$password@/api/v1/public/patrons/$borrowernumber/self_renewal" => json => $modification_data ) |
| 207 |
->status_is( 201, 'REST3.2.2' ) |
214 |
->status_is( 201, 'REST3.2.2' ) |
| 208 |
->json_is( { expiry_date => $expiry_date->truncate( to => 'day' ), confirmation_sent => 1 } ); |
215 |
->json_is( { expiry_date => $expiry_date->truncate( to => 'day' ), confirmation_sent => 1 } ); |
| 209 |
|
216 |
|
| 210 |
- |
|
|