[Rt-commit] rt branch, 4.0/preserve-ticket-basics, created. rt-4.0.18-105-g6dae9cd

Alex Vandiver alexmv at bestpractical.com
Wed Nov 27 16:54:58 EST 2013


The branch, 4.0/preserve-ticket-basics has been created
        at  6dae9cdcc9263e1baa8f5037e3d66668008bcf0a (commit)

- Log -----------------------------------------------------------------
commit d7ed4679966d45a413d453e1ed54df256a5a96ac
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Aug 3 11:39:59 2011 -0400

    Preerve time units (checkpoint)

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 8611102..e353a70 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -173,6 +173,28 @@ sub goto_create_ticket {
     return 1;
 }
 
+sub goto_update_ticket {
+    my $self = shift;
+    my %args = @_;
+    my ($ticket, $action) = @args{'ticket', 'action'};
+    for ('ticket', 'action') {
+        die "'$_' parameter required for goto_update_ticket" unless $args{$_};
+    }
+
+    my $id;
+    if ( ref $ticket ) {
+        $id = $ticket->id;
+    } elsif ( $ticket =~ /^\d+$/ ) {
+        $id = $ticket;
+    } else {
+        die "not yet implemented";
+    }
+
+    $self->get($self->rt_base_url . 'Ticket/Update.html?id='.$id.'&Action='.$action);
+
+    return 1;
+}
+
 sub get_warnings {
     my $self = shift;
     local $Test::Builder::Level = $Test::Builder::Level + 1;
diff --git a/share/html/Admin/CustomFields/Objects.html b/share/html/Admin/CustomFields/Objects.html
index 26183ac..6e46aaf 100644
--- a/share/html/Admin/CustomFields/Objects.html
+++ b/share/html/Admin/CustomFields/Objects.html
@@ -50,7 +50,7 @@
 
 <& /Elements/ListActions, actions => \@results &>
 
-<form action="Objects.html" method="post">
+<form action="Objects.html" name="CustomFieldAppliesTo" method="post">
 <input type="hidden" class="hidden" name="id" value="<% $id %>" />
 
 % if ( $is_global ) {
diff --git a/share/html/Elements/EditTimeValue b/share/html/Elements/EditTimeValue
index fc87813..b19d5c2 100644
--- a/share/html/Elements/EditTimeValue
+++ b/share/html/Elements/EditTimeValue
@@ -46,20 +46,22 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <input name="<% $ValueName %>" value="<% $Default || '' %>" size="5" />
-<& /Elements/SelectTimeUnits, Name => $UnitName &>
+<& /Elements/SelectTimeUnits, Name => $UnitName, Default => $show_units &>
 <%ARGS>
 $Default    => ''
 $Name       => ''
 $ValueName  => ''
-$UnitName   => ''
-$InputUnits => 'minutes'
 </%ARGS>
 <%INIT>
-$ValueName ||= $Name;
-$UnitName  ||= ($Name||$ValueName) . '-TimeUnits';
+$ValueName  ||= $Name;
+my $UnitName  = $ValueName . '-TimeUnits';
 
-if ($InputUnits eq 'minutes' && RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'})) {
-    $Default = sprintf '%.3f', $Default / 60
-        unless $Default eq '';
+my $show_units = $m->request_args->{ $UnitName };
+$show_units ||= RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'});
+$show_units ||= 'minutes';
+
+if ( $Default && $show_units eq 'hours' ) {
+    $Default = sprintf '%.3f', $Default / 60;
+    $Default =~ s/\.000$//;
 }
 </%INIT>
diff --git a/share/html/Elements/SelectTimeUnits b/share/html/Elements/SelectTimeUnits
index f6e7c9b..c32f982 100644
--- a/share/html/Elements/SelectTimeUnits
+++ b/share/html/Elements/SelectTimeUnits
@@ -46,17 +46,17 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <select class="TimeUnits" id="<% $Name %>" name="<% $Name %>">
-<option value="minutes" <% $HoursDefault ? '' : 'selected="selected"' |n%>>
+<option value="minutes" <% $Default eq 'minutes' ? '' : 'selected="selected"' |n%>>
     <% loc('Minutes') %>
 </option>
-<option value="hours"   <% $HoursDefault ? 'selected="selected"' : '' |n%>>
+<option value="hours"   <% $Default eq 'hours'   ? 'selected="selected"' : '' |n%>>
     <% loc('Hours') %>
 </option>
 </select>
 <%INIT>
 $Name .= '-TimeUnits' unless $Name =~ /-TimeUnits$/io;
-my $HoursDefault = RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'});
 </%INIT>
 <%ARGS>
 $Name => ''
+$Default => 'minutes'
 </%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index d7ac0c9..55214a9 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -189,7 +189,7 @@
         <& /Ticket/Elements/AddAttachments, %ARGS, QueueObj => $QueueObj &>
       </table>
     </&>
-    <& /Elements/Submit, Label => loc("Create"), id => 'SubmitTicket' &>
+    <& /Elements/Submit, Label => loc("Create"), Name => 'SubmitTicket', id => 'SubmitTicket' &>
   </div>
 </div>
 
@@ -215,17 +215,17 @@
 &></td></tr>
 <tr><td class="label"><&|/l&>Time Estimated</&>:</td>
 <td>
-<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InUnits => $ARGS{'TimeEstimated-TimeUnits'} &>
+<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '' &>
 
 </td></tr>
 <tr><td class="label"><&|/l&>Time Worked</&>:</td>
 <td>
-<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InUnits => $ARGS{'TimeWorked-TimeUnits'} &>
+<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '' &>
 </td></tr>
 <tr>
 <td class="label"><&|/l&>Time Left</&>:</td>
 <td>
-<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InUnits => $ARGS{'TimeLeft-TimeUnits'} &>
+<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '' &>
 </td></tr>
 </table>
 </&>
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index d67bba0..0d94341 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -128,7 +128,6 @@
             args => {
                 Name => 'UpdateTimeWorked',
                 Default => $ARGS{UpdateTimeWorked}||'',
-                InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
             }
         },
     ]
diff --git a/share/html/m/ticket/create b/share/html/m/ticket/create
index 9fd04e4..d20178b 100644
--- a/share/html/m/ticket/create
+++ b/share/html/m/ticket/create
@@ -353,21 +353,18 @@ $showrows->(
         "/Elements/EditTimeValue",
         Name    => 'TimeEstimated',
         Default => $ARGS{TimeEstimated} || '',
-        InUnits => $ARGS{'TimeEstimated-TimeUnits'}
         ).'</span>',
 
     loc("Time Worked") => '<span class="timefield">'.$m->scomp(
         "/Elements/EditTimeValue",
         Name    => 'TimeWorked',
         Default => $ARGS{TimeWorked} || '',
-        InUnits => $ARGS{'TimeWorked-TimeUnits'}
     ). '</span>',
 
     loc("Time Left") => '<span class="timefield">'.$m->scomp(
         "/Elements/EditTimeValue",
         Name    => 'TimeLeft',
         Default => $ARGS{TimeLeft} || '',
-        InUnits => $ARGS{'TimeLeft-TimeUnits'}
     ).'</span>',
 );
 
diff --git a/share/html/m/ticket/reply b/share/html/m/ticket/reply
index d3b0f6f..a5d5f40 100644
--- a/share/html/m/ticket/reply
+++ b/share/html/m/ticket/reply
@@ -78,7 +78,6 @@
 <& /Elements/EditTimeValue,
     Name => 'UpdateTimeWorked',
     Default => $ARGS{UpdateTimeWorked}||'',
-    InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
 &>
 </span></div>
 % $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $t );
diff --git a/t/web/ticket_basics.t b/t/web/ticket_basics.t
new file mode 100644
index 0000000..e396400
--- /dev/null
+++ b/t/web/ticket_basics.t
@@ -0,0 +1,84 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 47;
+
+my $ticket = RT::Test->create_ticket(
+    Subject => 'test ticket basics',
+    Queue   => 1,
+);
+
+my ( $url, $m ) = RT::Test->started_ok;
+ok( $m->login, 'logged in' );
+
+# Failing test where the time units are not preserved when you
+# click 'Add more files' on Display
+my @form_tries = (
+    {TimeEstimated => undef},
+    {TimeEstimated => "1"},
+    {TimeWorked    => undef},
+    {TimeWorked    => "1"},
+    {TimeLeft      => undef},
+    {TimeLeft      => "1"},
+);
+for my $try (@form_tries) {
+    $m->goto_create_ticket(1);
+    $m->form_name('TicketCreate');
+    for my $field (keys %$try) {
+        $m->select("${field}-TimeUnits" => 'hours');
+        $m->field($field => $try->{$field}) if defined $try->{$field};
+        $m->click('AddMoreAttach');
+        $m->form_name('TicketCreate');
+        is($m->value("${field}-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
+    }
+}
+
+$m->goto_update_ticket(ticket => $ticket, action => 'Respond');
+$m->form_name('TicketUpdate');
+$m->select("UpdateTimeWorked-TimeUnits" => 'hours');
+$m->click('AddMoreAttach');
+$m->form_name('TicketUpdate');
+is($m->value("UpdateTimeWorked-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
+
+my $cf = RT::Test->load_or_create_custom_field(
+    Name       => 'CF1',
+    Type       => 'Freeform',
+    Pattern    => '.', # mandatory
+    Queue      => 'General',
+);
+
+# More time unit testing by a failing CF validation
+$m->get_ok($url.'/Admin/CustomFields/Objects.html?id='.$cf->id);
+$m->form_name('CustomFieldAppliesTo');
+$m->tick('AddCustomField-'.$cf->id => '0'); # Make CF global
+$m->click('UpdateObjs');
+$m->text_contains('Object created', 'CF applied globally');
+
+$m->goto_create_ticket(1);
+
+$m->form_name('TicketCreate');
+$m->field('TimeWorked-TimeUnits' => 'hours');
+$m->click('SubmitTicket');
+
+$m->form_name('TicketCreate');
+is($m->value("TimeWorked-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
+
+
+# Test for time unit preservation in Jumbo
+for my $try (@form_tries) {
+    my $jumbo_ticket = RT::Test->create_ticket(
+        Subject => 'test jumbo ticket basics',
+        Queue   => 1,
+    );
+
+    $m->get_ok( $url . "/Ticket/ModifyAll.html?id=" . $jumbo_ticket->id );
+
+    for my $field (keys %$try) {
+        $m->form_name('TicketModifyAll');
+        $m->field("${field}" => "1");
+        $m->select("${field}-TimeUnits" => 'hours');
+        $m->click('AddMoreAttach');
+        $m->form_name('TicketModifyAll');
+        is($m->value("${field}-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
+    }
+}

commit f1f88feaaf5ced3c8251826ff16083c896d2eecb
Author: Jason May <jasonmay at bestpractical.com>
Date:   Thu Nov 3 15:56:38 2011 -0400

    Preserve time fields in Jumbo by passing the comp args as defaults

diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index c5bb6bb..b4fc37f 100644
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -56,7 +56,12 @@
 <input type="hidden" class="hidden" name="id" value="<%$Ticket->Id%>" />
 
 <&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
-<& Elements/EditBasics, TicketObj => $Ticket &>
+% my @preserve_fields = qw(
+%     TimeWorked TimeEstimated TimeLeft
+% );
+<& Elements/EditBasics,
+    TicketObj => $Ticket,
+    defaults => { map { $_ => $ARGS{$_} } @preserve_fields } &>
 <& Elements/EditCustomFields, TicketObj => $Ticket &>
 </&>
 
diff --git a/t/web/ticket_basics.t b/t/web/ticket_basics.t
index e396400..d149c22 100644
--- a/t/web/ticket_basics.t
+++ b/t/web/ticket_basics.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 47;
+use RT::Test tests => 59;
 
 my $ticket = RT::Test->create_ticket(
     Subject => 'test ticket basics',
@@ -30,6 +30,11 @@ for my $try (@form_tries) {
         $m->click('AddMoreAttach');
         $m->form_name('TicketCreate');
         is($m->value("${field}-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
+        is(
+            $m->value($field),
+            defined($try->{$field}) ? $try->{$field} : '',
+            'time value is the same after the form was submitted'
+        );
     }
 }
 
@@ -75,10 +80,15 @@ for my $try (@form_tries) {
 
     for my $field (keys %$try) {
         $m->form_name('TicketModifyAll');
-        $m->field("${field}" => "1");
+        $m->field($field => $try->{$field}) if defined $try->{$field};
         $m->select("${field}-TimeUnits" => 'hours');
         $m->click('AddMoreAttach');
         $m->form_name('TicketModifyAll');
         is($m->value("${field}-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
+        is(
+            $m->value($field),
+            defined($try->{$field}) ? $try->{$field} : '',
+            'time value is the same after the form was submitted'
+        );
     }
 }

commit 7ffa0c1df75ae7459e5dc2d6fc6268b85c64d729
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Aug 3 12:59:49 2011 -0400

    Use $Action instead of $ARGS{'Action'} to get the 'default value' for free

diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 0d94341..f7d3ac7 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -56,7 +56,7 @@
 % $m->callback( CallbackName => 'FormStart', ARGSRef => \%ARGS, Ticket => $TicketObj, CanRespond => $CanRespond, CanComment => $CanComment, ResponseDefault => $ResponseDefault, CommentDefault => $CommentDefault );
 <input type="hidden" class="hidden" name="QuoteTransaction" value="<% $ARGS{QuoteTransaction}||'' %>" />
 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
-<input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
+<input type="hidden" class="hidden" name="Action" value="<% $Action %>" />
 
 <& /Elements/GnuPG/SignEncryptWidget:ShowIssues, self => $gnupg_widget &>
 
@@ -238,8 +238,8 @@ if ($Action ne 'Respond') {
 }
 
 my $type =             $ARGS{'UpdateType'} ? $ARGS{'UpdateType'} :
-           lc $ARGS{'Action'} eq 'respond' ? 'response'          :
-           lc $ARGS{'Action'} eq 'comment' ? 'private'           :
+           lc $Action eq 'respond' ? 'response'          :
+           lc $Action eq 'comment' ? 'private'           :
                                              'none'              ;
 
 

commit fcd9938851aa7b3782549e853ea17d1bf225024e
Author: Jason May <jasonmay at bestpractical.com>
Date:   Thu Nov 3 18:21:59 2011 -0400

    Preserve the rest of the ticket basics in Jumbo
    
    When AddMoreAttach is clicked in Jumbo, Status, Subject, Owner, and
    others are preserved.
    
    Also, Owner is now disambiguated whether AddMoreAttach is clicked or
    not. This was needed, because an owner needs to be passed the preserved
    arg into the owner field component.

diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index b4fc37f..1984f8d 100644
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -57,7 +57,9 @@
 
 <&| /Widgets/TitleBox, title => loc('Modify ticket # [_1]', $Ticket->Id), class=>'ticket-info-basics' &>
 % my @preserve_fields = qw(
+%     Status Subject Owner
 %     TimeWorked TimeEstimated TimeLeft
+%     Priority FinalPriority
 % );
 <& Elements/EditBasics,
     TicketObj => $Ticket,
@@ -162,7 +164,7 @@ ProcessAttachments(ARGSRef => \%ARGS);
 $m->callback( TicketObj => $Ticket, ARGSRef => \%ARGS );
 my @results;
 
-unless ($OnlySearchForPeople or $OnlySearchForGroup or $ARGS{'AddMoreAttach'} ) {
+unless ($OnlySearchForPeople or $OnlySearchForGroup ) {
     # There might be two owners. 
     if ( ref ($ARGS{'Owner'} )) {
         my @owners =@{$ARGS{'Owner'}};
@@ -178,18 +180,20 @@ unless ($OnlySearchForPeople or $OnlySearchForGroup or $ARGS{'AddMoreAttach'} )
 
     }
 
-    push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
-    push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS);
-    push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
-    
-    # Add session attachments if any to be processed by ProcessUpdateMessage
-    $ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );
-    push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
-    # Cleanup WebUI
-    delete $session{'Attachments'};
-
-    push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
-    push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
+    unless ( $ARGS{'AddMoreAttach'} ) {
+        push @results, ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
+        push @results, ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS);
+        push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
+        
+        # Add session attachments if any to be processed by ProcessUpdateMessage
+        $ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );
+        push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
+        # Cleanup WebUI
+        delete $session{'Attachments'};
+
+        push @results, ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS );
+        push @results, ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
+    }
 }
 
 $Ticket->ApplyTransactionBatch;
diff --git a/t/web/ticket_basics.t b/t/web/ticket_basics.t
index d149c22..a69c4c9 100644
--- a/t/web/ticket_basics.t
+++ b/t/web/ticket_basics.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 59;
+use RT::Test tests => 77;
 
 my $ticket = RT::Test->create_ticket(
     Subject => 'test ticket basics',
@@ -11,40 +11,51 @@ my $ticket = RT::Test->create_ticket(
 my ( $url, $m ) = RT::Test->started_ok;
 ok( $m->login, 'logged in' );
 
+my $change_to_owner = do {
+    $m->get( $url . "/Ticket/ModifyAll.html?id=" . $ticket->id );
+    my $form = $m->form_name('ModifyTicket');
+    my @values = $form->find_input('Owner')->possible_values;
+    $values[-1];
+};
 # Failing test where the time units are not preserved when you
 # click 'Add more files' on Display
 my @form_tries = (
-    {TimeEstimated => undef},
-    {TimeEstimated => "1"},
-    {TimeWorked    => undef},
-    {TimeWorked    => "1"},
-    {TimeLeft      => undef},
-    {TimeLeft      => "1"},
+    {Subject => "hello rt"},
+    {Status  => "open"},
+    {Owner   => $change_to_owner},
+
+    (
+        map +{
+            "Time$_"           => undef,
+            "Time$_-TimeUnits" => 'hours',
+        }, qw/Estimated Worked Left/
+    ),
+    (
+        map +{
+            "Time$_"           => '1',
+            "Time$_-TimeUnits" => 'hours',
+        }, qw/Estimated Worked Left/
+    ),
+
+    {InitialPriority      => "10"},
+    {FinalPriority => "10"},
 );
+
 for my $try (@form_tries) {
     $m->goto_create_ticket(1);
     $m->form_name('TicketCreate');
+    $m->set_fields(%$try);
+    $m->click('AddMoreAttach');
+    $m->form_name('TicketCreate');
     for my $field (keys %$try) {
-        $m->select("${field}-TimeUnits" => 'hours');
-        $m->field($field => $try->{$field}) if defined $try->{$field};
-        $m->click('AddMoreAttach');
-        $m->form_name('TicketCreate');
-        is($m->value("${field}-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
         is(
             $m->value($field),
             defined($try->{$field}) ? $try->{$field} : '',
-            'time value is the same after the form was submitted'
+            "field $field is the same after the form was submitted"
         );
     }
 }
 
-$m->goto_update_ticket(ticket => $ticket, action => 'Respond');
-$m->form_name('TicketUpdate');
-$m->select("UpdateTimeWorked-TimeUnits" => 'hours');
-$m->click('AddMoreAttach');
-$m->form_name('TicketUpdate');
-is($m->value("UpdateTimeWorked-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
-
 my $cf = RT::Test->load_or_create_custom_field(
     Name       => 'CF1',
     Type       => 'Freeform',
@@ -76,19 +87,20 @@ for my $try (@form_tries) {
         Queue   => 1,
     );
 
-    $m->get_ok( $url . "/Ticket/ModifyAll.html?id=" . $jumbo_ticket->id );
+    local($try->{Priority}) = delete local($try->{InitialPriority})
+        if exists $try->{InitialPriority};
 
+    $m->get( $url . "/Ticket/ModifyAll.html?id=" . $jumbo_ticket->id );
+    $m->form_name('TicketModifyAll');
+    $m->set_fields(%$try);
+    $m->click('AddMoreAttach');
+    $m->form_name('TicketModifyAll');
     for my $field (keys %$try) {
-        $m->form_name('TicketModifyAll');
-        $m->field($field => $try->{$field}) if defined $try->{$field};
-        $m->select("${field}-TimeUnits" => 'hours');
-        $m->click('AddMoreAttach');
-        $m->form_name('TicketModifyAll');
-        is($m->value("${field}-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
         is(
             $m->value($field),
             defined($try->{$field}) ? $try->{$field} : '',
-            'time value is the same after the form was submitted'
+            "field $field is the same after the Jumbo form was submitted"
         );
     }
 }
+

commit 6dae9cdcc9263e1baa8f5037e3d66668008bcf0a
Author: Jason May <jasonmay at bestpractical.com>
Date:   Thu Nov 3 18:59:17 2011 -0400

    Improve coverage for testing preserved fields on failed CF validation

diff --git a/t/web/ticket_basics.t b/t/web/ticket_basics.t
index a69c4c9..4f289c4 100644
--- a/t/web/ticket_basics.t
+++ b/t/web/ticket_basics.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 77;
+use RT::Test tests => 93;
 
 my $ticket = RT::Test->create_ticket(
     Subject => 'test ticket basics',
@@ -56,30 +56,6 @@ for my $try (@form_tries) {
     }
 }
 
-my $cf = RT::Test->load_or_create_custom_field(
-    Name       => 'CF1',
-    Type       => 'Freeform',
-    Pattern    => '.', # mandatory
-    Queue      => 'General',
-);
-
-# More time unit testing by a failing CF validation
-$m->get_ok($url.'/Admin/CustomFields/Objects.html?id='.$cf->id);
-$m->form_name('CustomFieldAppliesTo');
-$m->tick('AddCustomField-'.$cf->id => '0'); # Make CF global
-$m->click('UpdateObjs');
-$m->text_contains('Object created', 'CF applied globally');
-
-$m->goto_create_ticket(1);
-
-$m->form_name('TicketCreate');
-$m->field('TimeWorked-TimeUnits' => 'hours');
-$m->click('SubmitTicket');
-
-$m->form_name('TicketCreate');
-is($m->value("TimeWorked-TimeUnits"), 'hours', 'time units stayed to "hours" after the form was submitted');
-
-
 # Test for time unit preservation in Jumbo
 for my $try (@form_tries) {
     my $jumbo_ticket = RT::Test->create_ticket(
@@ -104,3 +80,32 @@ for my $try (@form_tries) {
     }
 }
 
+my $cf = RT::Test->load_or_create_custom_field(
+    Name       => 'CF1',
+    Type       => 'Freeform',
+    Pattern    => '.', # mandatory
+    Queue      => 'General',
+);
+
+# More time unit testing by a failing CF validation
+$m->get_ok($url.'/Admin/CustomFields/Objects.html?id='.$cf->id);
+$m->form_name('CustomFieldAppliesTo');
+$m->tick('AddCustomField-'.$cf->id => '0'); # Make CF global
+$m->click('UpdateObjs');
+$m->text_contains('Object created', 'CF applied globally');
+
+# Test for preservation when a ticket is submitted and CF validation fails
+for my $try (@form_tries) {
+    $m->goto_create_ticket(1);
+    $m->form_name('TicketCreate');
+    $m->set_fields(%$try);
+    $m->click('SubmitTicket');
+    $m->form_name('TicketCreate');
+    for my $field (keys %$try) {
+        is(
+            $m->value($field),
+            defined($try->{$field}) ? $try->{$field} : '',
+            "field $field is the same after the form was submitted"
+        );
+    }
+}

-----------------------------------------------------------------------


More information about the rt-commit mailing list