]> git.pld-linux.org Git - packages/rt.git/blob - rt-timeworked.patch
Up to 5.0.2.
[packages/rt.git] / rt-timeworked.patch
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'} ) {
4      }
5  }
6  
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;
13 +    }
14 +}
15 +
16  # check email addresses for RT's
17  {
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"; {
24      );
25  }
26  
27 +diag "checking invalid and edge cased worked time on update";
28 +{
29 +    my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => "timeworked", TimeWorked => 30, );
30 +    my $time = $ticket->TimeWorked;
31 +    is( $time, 30, "current TimeWorked" );
32 +
33 +    $m->goto_ticket( $ticket->id, 'Update' );
34 +    $m->submit_form_ok(
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"' );
38 +
39 +    $ticket->Load( $ticket->id );
40 +    is( $ticket->TimeWorked, 30, 'TimeWorked is not updated' );
41 +
42 +
43 +    $m->submit_form_ok(
44 +        {
45 +            form_name => 'TicketUpdate',
46 +            fields    => { UpdateTimeWorked => '1.5', 'UpdateTimeWorked-TimeUnits' => 'hours' },
47 +            button    => 'SubmitTicket',
48 +        },
49 +        'update TimeWorked with 1.5 hours'
50 +    );
51 +    $m->text_lacks( 'Invalid worked time, should be numeric' );
52 +    $ticket->Load( $ticket->id );
53 +    is( $ticket->TimeWorked, 120, 'TimeWorked is updated' );
54 +
55 +    $m->goto_ticket( $ticket->id, 'Update' );
56 +    $m->submit_form_ok(
57 +        {
58 +            form_name => 'TicketUpdate',
59 +            fields    => { UpdateTimeWorked => '.5', 'UpdateTimeWorked-TimeUnits' => 'hours' },
60 +            button    => 'SubmitTicket',
61 +        },
62 +        'update TimeWorked with .5 hours'
63 +    );
64 +    $m->text_lacks( 'Invalid worked time, should be numeric' );
65 +    $ticket->Load( $ticket->id );
66 +    is( $ticket->TimeWorked, 150, 'TimeWorked is updated' );
67 +
68 +    $m->goto_ticket( $ticket->id, 'Update' );
69 +    $m->submit_form_ok(
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' );
75 +
76 +    $m->goto_ticket( $ticket->id, 'Update' );
77 +    $m->submit_form_ok(
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' );
83 +
84 +    $m->goto_ticket( $ticket->id, 'Update' );
85 +    $m->submit_form_ok(
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' );
91 +}
92 +
93  done_testing();
This page took 0.073514 seconds and 3 git commands to generate.