|
Lines 118-124
subtest 'list_updates() tests' => sub {
Link Here
|
| 118 |
|
118 |
|
| 119 |
subtest 'add_update() tests' => sub { |
119 |
subtest 'add_update() tests' => sub { |
| 120 |
|
120 |
|
| 121 |
plan tests => 37; |
121 |
plan tests => 60; |
| 122 |
|
122 |
|
| 123 |
$schema->storage->txn_begin; |
123 |
$schema->storage->txn_begin; |
| 124 |
|
124 |
|
|
Lines 174-179
subtest 'add_update() tests' => sub {
Link Here
|
| 174 |
'SWAGGER3.4.1' |
174 |
'SWAGGER3.4.1' |
| 175 |
)->json_is( '/message' => $update->{message} ) |
175 |
)->json_is( '/message' => $update->{message} ) |
| 176 |
->json_is( '/public' => $update->{public} ) |
176 |
->json_is( '/public' => $update->{public} ) |
|
|
177 |
->json_is( '/status' => undef ) |
| 178 |
->json_is( '/assignee_id' => undef ) |
| 177 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
179 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
| 178 |
|
180 |
|
| 179 |
# Check that notice trigger didn't fire for non-public update |
181 |
# Check that notice trigger didn't fire for non-public update |
|
Lines 226-231
subtest 'add_update() tests' => sub {
Link Here
|
| 226 |
'SWAGGER3.4.1' |
228 |
'SWAGGER3.4.1' |
| 227 |
)->json_is( '/message' => $update->{message} ) |
229 |
)->json_is( '/message' => $update->{message} ) |
| 228 |
->json_is( '/public' => $update->{public} ) |
230 |
->json_is( '/public' => $update->{public} ) |
|
|
231 |
->json_is( '/status' => undef ) |
| 232 |
->json_is( '/assignee_id' => undef ) |
| 229 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
233 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
| 230 |
|
234 |
|
| 231 |
$notices = |
235 |
$notices = |
|
Lines 240-246
subtest 'add_update() tests' => sub {
Link Here
|
| 240 |
|
244 |
|
| 241 |
# Check that state change triggers correct notice |
245 |
# Check that state change triggers correct notice |
| 242 |
$update->{state} = 'resolved'; |
246 |
$update->{state} = 'resolved'; |
| 243 |
$update->{status} = 'TEST'; |
|
|
| 244 |
$update_id = |
247 |
$update_id = |
| 245 |
$t->post_ok( |
248 |
$t->post_ok( |
| 246 |
"//$userid:$password@/api/v1/tickets/$ticket_id/updates" => json => |
249 |
"//$userid:$password@/api/v1/tickets/$ticket_id/updates" => json => |
|
Lines 249-254
subtest 'add_update() tests' => sub {
Link Here
|
| 249 |
'SWAGGER3.4.1' |
252 |
'SWAGGER3.4.1' |
| 250 |
)->json_is( '/message' => $update->{message} ) |
253 |
)->json_is( '/message' => $update->{message} ) |
| 251 |
->json_is( '/public' => $update->{public} ) |
254 |
->json_is( '/public' => $update->{public} ) |
|
|
255 |
->json_is( '/status' => undef ) |
| 256 |
->json_is( '/assignee_id' => undef ) |
| 252 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
257 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
| 253 |
|
258 |
|
| 254 |
$notices = |
259 |
$notices = |
|
Lines 268-278
subtest 'add_update() tests' => sub {
Link Here
|
| 268 |
); |
273 |
); |
| 269 |
isnt( $ticket->resolved_date, undef, "Ticket was given resolved_date when state was updated to 'resolved'" ); |
274 |
isnt( $ticket->resolved_date, undef, "Ticket was given resolved_date when state was updated to 'resolved'" ); |
| 270 |
|
275 |
|
|
|
276 |
$update->{public} = Mojo::JSON->false; |
| 277 |
$update->{state} = undef; |
| 278 |
|
| 271 |
# Check that status change is carried over to ticket |
279 |
# Check that status change is carried over to ticket |
|
|
280 |
$update->{status} = 'TEST'; |
| 281 |
$update_id = |
| 282 |
$t->post_ok( |
| 283 |
"//$userid:$password@/api/v1/tickets/$ticket_id/updates" => json => |
| 284 |
$update )->status_is( 201, 'SWAGGER3.2.1' )->header_like( |
| 285 |
Location => qr|^\/api\/v1\/tickets/\d*|, |
| 286 |
'SWAGGER3.4.1' |
| 287 |
)->json_is( '/message' => $update->{message} ) |
| 288 |
->json_is( '/public' => $update->{public} ) |
| 289 |
->json_is( '/status' => $update->{status} ) |
| 290 |
->json_is( '/assignee_id' => undef ) |
| 291 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
| 292 |
|
| 293 |
$ticket = $ticket->get_from_storage; |
| 272 |
is( |
294 |
is( |
| 273 |
$ticket->status, 'TEST', |
295 |
$ticket->status, 'TEST', |
| 274 |
"Ticket status was updated in line with status change in update" |
296 |
"Ticket status was updated in line with status change in update" |
| 275 |
); |
297 |
); |
| 276 |
|
298 |
|
|
|
299 |
$update->{status} = undef; |
| 300 |
|
| 301 |
# Check that assignee is carried over to ticket |
| 302 |
$update->{assignee_id} = $librarian->id; |
| 303 |
$update_id = |
| 304 |
$t->post_ok( |
| 305 |
"//$userid:$password@/api/v1/tickets/$ticket_id/updates" => json => |
| 306 |
$update )->status_is( 201, 'SWAGGER3.2.1' )->header_like( |
| 307 |
Location => qr|^\/api\/v1\/tickets/\d*|, |
| 308 |
'SWAGGER3.4.1' |
| 309 |
)->json_is( '/message' => $update->{message} ) |
| 310 |
->json_is( '/public' => $update->{public} ) |
| 311 |
->json_is( '/status' => $update->{status} ) |
| 312 |
->json_is( '/assignee_id' => $update->{assignee_id} ) |
| 313 |
->json_is( '/user_id' => $librarian->id )->tx->res->json->{update_id}; |
| 314 |
|
| 315 |
$ticket = $ticket->get_from_storage; |
| 316 |
is( |
| 317 |
$ticket->assignee_id, $update->{assignee_id}, |
| 318 |
"Ticket assignee was updated in line with assignee change in update" |
| 319 |
); |
| 320 |
|
| 277 |
$schema->storage->txn_rollback; |
321 |
$schema->storage->txn_rollback; |
| 278 |
}; |
322 |
}; |
| 279 |
- |
|
|