1 --- rt-5.0.2/share/html/Ticket/Update.html~ 2021-09-14 23:42:01.000000000 +0200
2 +++ rt-5.0.2/share/html/Ticket/Update.html 2022-01-31 12:57:47.459829737 +0100
3 @@ -410,6 +410,15 @@ if ( $ARGS{'SubmitTicket'} ) {
7 +if ( $ARGS{UpdateTimeWorked} ) {
8 + $ARGS{UpdateTimeWorked} =~ s!^\s+!!;
9 + $ARGS{UpdateTimeWorked} =~ s!\s+$!!;
10 + if ( $ARGS{UpdateTimeWorked} !~ /^(?:\d+)?(?:\.(?:\d+)?)?$/ ) {
11 + push @results, loc('Invalid worked time, should be numeric: "[_1]"', $ARGS{UpdateTimeWorked});
12 + $checks_failure = 1;
16 # check email addresses for RT's
18 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
19 diff --git a/t/web/ticket_timeworked.t b/t/web/ticket_timeworked.t
20 index dc52cebd84..16ad0f03a9 100644
21 --- a/t/web/ticket_timeworked.t
22 +++ b/t/web/ticket_timeworked.t
23 @@ -146,4 +146,70 @@ diag "checking child ticket 2 for expected timeworked data"; {
27 +diag "checking invalid and edge cased worked time on update";
29 + my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => "timeworked", TimeWorked => 30, );
30 + my $time = $ticket->TimeWorked;
31 + is( $time, 30, "current TimeWorked" );
33 + $m->goto_ticket( $ticket->id, 'Update' );
35 + { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => '0,1', }, button => 'SubmitTicket', },
36 + 'update TimeWorked with "0,1"' );
37 + $m->text_contains( 'Invalid worked time, should be numeric: "0,1"' );
39 + $ticket->Load( $ticket->id );
40 + is( $ticket->TimeWorked, 30, 'TimeWorked is not updated' );
45 + form_name => 'TicketUpdate',
46 + fields => { UpdateTimeWorked => '1.5', 'UpdateTimeWorked-TimeUnits' => 'hours' },
47 + button => 'SubmitTicket',
49 + 'update TimeWorked with 1.5 hours'
51 + $m->text_lacks( 'Invalid worked time, should be numeric' );
52 + $ticket->Load( $ticket->id );
53 + is( $ticket->TimeWorked, 120, 'TimeWorked is updated' );
55 + $m->goto_ticket( $ticket->id, 'Update' );
58 + form_name => 'TicketUpdate',
59 + fields => { UpdateTimeWorked => '.5', 'UpdateTimeWorked-TimeUnits' => 'hours' },
60 + button => 'SubmitTicket',
62 + 'update TimeWorked with .5 hours'
64 + $m->text_lacks( 'Invalid worked time, should be numeric' );
65 + $ticket->Load( $ticket->id );
66 + is( $ticket->TimeWorked, 150, 'TimeWorked is updated' );
68 + $m->goto_ticket( $ticket->id, 'Update' );
70 + { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => '5.' }, button => 'SubmitTicket', },
71 + 'update TimeWorked 5. minutes' );
72 + $m->text_lacks( 'Invalid worked time, should be numeric' );
73 + $ticket->Load( $ticket->id );
74 + is( $ticket->TimeWorked, 155, 'TimeWorked is updated' );
76 + $m->goto_ticket( $ticket->id, 'Update' );
78 + { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => ' 15 ' }, button => 'SubmitTicket', },
79 + 'update TimeWorked with " 15 "' );
80 + $m->text_lacks( 'Invalid worked time, should be numeric' );
81 + $ticket->Load( $ticket->id );
82 + is( $ticket->TimeWorked, 170, 'TimeWorked is updated' );
84 + $m->goto_ticket( $ticket->id, 'Update' );
86 + { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => ' ' }, button => 'SubmitTicket', },
87 + 'update TimeWorked with just a space' );
88 + $m->text_lacks( 'Invalid worked time, should be numeric' );
89 + $ticket->Load( $ticket->id );
90 + is( $ticket->TimeWorked, 170, 'TimeWorked is not updated' );