]> git.pld-linux.org Git - packages/rt.git/blame - rt-timeworked.patch
Up to 4.4.5.
[packages/rt.git] / rt-timeworked.patch
CommitLineData
90613187
AM
1diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
2index 6e73b50a81..ce81bf6c97 100644
3--- a/share/html/Ticket/Update.html
4+++ b/share/html/Ticket/Update.html
5@@ -333,6 +333,15 @@ if ( $ARGS{'SubmitTicket'} ) {
ab812d7f 6 }
90613187
AM
7 }
8
9+if ( $ARGS{UpdateTimeWorked} ) {
10+ $ARGS{UpdateTimeWorked} =~ s!^\s+!!;
11+ $ARGS{UpdateTimeWorked} =~ s!\s+$!!;
12+ if ( $ARGS{UpdateTimeWorked} !~ /^(?:\d+)?(?:\.(?:\d+)?)?$/ ) {
13+ push @results, loc('Invalid worked time, should be numeric: "[_1]"', $ARGS{UpdateTimeWorked});
14+ $checks_failure = 1;
15+ }
16+}
17+
18 # check email addresses for RT's
19 {
20 foreach my $field ( qw(UpdateCc UpdateBcc) ) {
21diff --git a/t/web/ticket_timeworked.t b/t/web/ticket_timeworked.t
22index dc52cebd84..16ad0f03a9 100644
23--- a/t/web/ticket_timeworked.t
24+++ b/t/web/ticket_timeworked.t
25@@ -146,4 +146,70 @@ diag "checking child ticket 2 for expected timeworked data"; {
26 );
27 }
28
29+diag "checking invalid and edge cased worked time on update";
30+{
31+ my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => "timeworked", TimeWorked => 30, );
32+ my $time = $ticket->TimeWorked;
33+ is( $time, 30, "current TimeWorked" );
34+
35+ $m->goto_ticket( $ticket->id, 'Update' );
36+ $m->submit_form_ok(
37+ { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => '0,1', }, button => 'SubmitTicket', },
38+ 'update TimeWorked with "0,1"' );
39+ $m->text_contains( 'Invalid worked time, should be numeric: "0,1"' );
40+
41+ $ticket->Load( $ticket->id );
42+ is( $ticket->TimeWorked, 30, 'TimeWorked is not updated' );
43+
44+
45+ $m->submit_form_ok(
46+ {
47+ form_name => 'TicketUpdate',
48+ fields => { UpdateTimeWorked => '1.5', 'UpdateTimeWorked-TimeUnits' => 'hours' },
49+ button => 'SubmitTicket',
50+ },
51+ 'update TimeWorked with 1.5 hours'
52+ );
53+ $m->text_lacks( 'Invalid worked time, should be numeric' );
54+ $ticket->Load( $ticket->id );
55+ is( $ticket->TimeWorked, 120, 'TimeWorked is updated' );
56+
57+ $m->goto_ticket( $ticket->id, 'Update' );
58+ $m->submit_form_ok(
59+ {
60+ form_name => 'TicketUpdate',
61+ fields => { UpdateTimeWorked => '.5', 'UpdateTimeWorked-TimeUnits' => 'hours' },
62+ button => 'SubmitTicket',
63+ },
64+ 'update TimeWorked with .5 hours'
65+ );
66+ $m->text_lacks( 'Invalid worked time, should be numeric' );
67+ $ticket->Load( $ticket->id );
68+ is( $ticket->TimeWorked, 150, 'TimeWorked is updated' );
69+
70+ $m->goto_ticket( $ticket->id, 'Update' );
71+ $m->submit_form_ok(
72+ { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => '5.' }, button => 'SubmitTicket', },
73+ 'update TimeWorked 5. minutes' );
74+ $m->text_lacks( 'Invalid worked time, should be numeric' );
75+ $ticket->Load( $ticket->id );
76+ is( $ticket->TimeWorked, 155, 'TimeWorked is updated' );
77+
78+ $m->goto_ticket( $ticket->id, 'Update' );
79+ $m->submit_form_ok(
80+ { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => ' 15 ' }, button => 'SubmitTicket', },
81+ 'update TimeWorked with " 15 "' );
82+ $m->text_lacks( 'Invalid worked time, should be numeric' );
83+ $ticket->Load( $ticket->id );
84+ is( $ticket->TimeWorked, 170, 'TimeWorked is updated' );
85+
86+ $m->goto_ticket( $ticket->id, 'Update' );
87+ $m->submit_form_ok(
88+ { form_name => 'TicketUpdate', fields => { UpdateTimeWorked => ' ' }, button => 'SubmitTicket', },
89+ 'update TimeWorked with just a space' );
90+ $m->text_lacks( 'Invalid worked time, should be numeric' );
91+ $ticket->Load( $ticket->id );
92+ is( $ticket->TimeWorked, 170, 'TimeWorked is not updated' );
93+}
94+
95 done_testing();
This page took 0.099961 seconds and 4 git commands to generate.