[Rt-commit] rt branch, 4.0/preserve-time-units, created. rt-4.0.1-215-gdd4ef2e

Jason May jasonmay at bestpractical.com
Wed Aug 3 13:10:46 EDT 2011


The branch, 4.0/preserve-time-units has been created
        at  dd4ef2eae02e97bda238fbda5c03e45e9eec42ac (commit)

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

    Add tests to check that time units are preserved across form submits

diff --git a/t/web/ticket_modify_all.t b/t/web/ticket_modify_all.t
index a385c0e..2a9152f 100644
--- a/t/web/ticket_modify_all.t
+++ b/t/web/ticket_modify_all.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 12;
+use RT::Test tests => 15;
 
 my $ticket = RT::Test->create_ticket(
     Subject => 'test bulk update',
@@ -25,5 +25,13 @@ $m->content_lacks("this is update content", 'textarea is clear');
 $m->get_ok($url . '/Ticket/Display.html?id=' . $ticket->id );
 $m->content_contains("this is update content", 'updated content in display page');
 
-# XXX TODO test other parts, i.e. basic, dates, people and links
-
+# Failing test where the time units are not preserved when you
+# click 'Add more files' on Display
+for (qw/Estimated Worked Left/) {
+    $m->goto_create_ticket(1);
+    $m->form_name('TicketCreate');
+    $m->select("Time${_}-TimeUnits" => 'hours');
+    $m->click('AddMoreAttach');
+    $m->form_name('TicketCreate');
+    is ($m->value("Time${_}-TimeUnits"), 'hours', 'time units stayed to "hours" after the page was refreshed');
+}

commit dc46701c35aff9335ede0cf7104c83e7e0b0e684
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Aug 3 12:00:32 2011 -0400

    Preserve time units chosen across submits on the ticket-create form

diff --git a/share/html/Elements/EditTimeValue b/share/html/Elements/EditTimeValue
index 65ba8c5..54a0b50 100644
--- a/share/html/Elements/EditTimeValue
+++ b/share/html/Elements/EditTimeValue
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <input name="<% $ValueName %>" value="<% $Default || '' %>" size="5" />
-<& /Elements/SelectTimeUnits, Name => $UnitName &>
+<& /Elements/SelectTimeUnits, Name => $UnitName, InputUnits => $InputUnits &>
 <%ARGS>
 $Default    => ''
 $Name       => ''
diff --git a/share/html/Elements/SelectTimeUnits b/share/html/Elements/SelectTimeUnits
index b4c69f2..69ff4a2 100755
--- a/share/html/Elements/SelectTimeUnits
+++ b/share/html/Elements/SelectTimeUnits
@@ -45,11 +45,12 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
+% my $unit_selected = $HoursDefault ? 'hours' : $InputUnits;
 <select class="TimeUnits" id="<% $Name %>" name="<% $Name %>">
-<option value="minutes" <% $HoursDefault ? '' : 'selected="selected"' |n%>>
+<option value="minutes" <% $unit_selected eq 'hours' ? '' : 'selected="selected"' |n%>>
     <% loc('Minutes') %>
 </option>
-<option value="hours"   <% $HoursDefault ? 'selected="selected"' : '' |n%>>
+<option value="hours"   <% $unit_selected eq 'hours' ? 'selected="selected"' : '' |n%>>
     <% loc('Hours') %>
 </option>
 </select>
@@ -59,4 +60,5 @@ my $HoursDefault = RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentU
 </%INIT>
 <%ARGS>
 $Name => ''
+$InputUnits => 'minutes'
 </%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index fb70c2b..b4de5c0 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -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} || '', InputUnits => $ARGS{'TimeEstimated-TimeUnits'}||'minutes' &>
 
 </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} || '', InputUnits => $ARGS{'TimeWorked-TimeUnits'}||'minutes' &>
 </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} || '', InputUnits => $ARGS{'TimeLeft-TimeUnits'}||'minutes' &>
 </td></tr>
 </table>
 </&>

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

    Add tests for checking time units across submits for ticket updates

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 3be1b85..82a3e3c 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -176,6 +176,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/t/web/ticket_modify_all.t b/t/web/ticket_modify_all.t
index 2a9152f..3e20e12 100644
--- a/t/web/ticket_modify_all.t
+++ b/t/web/ticket_modify_all.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 15;
+use RT::Test tests => 16;
 
 my $ticket = RT::Test->create_ticket(
     Subject => 'test bulk update',
@@ -33,5 +33,12 @@ for (qw/Estimated Worked Left/) {
     $m->select("Time${_}-TimeUnits" => 'hours');
     $m->click('AddMoreAttach');
     $m->form_name('TicketCreate');
-    is ($m->value("Time${_}-TimeUnits"), 'hours', 'time units stayed to "hours" after the page was refreshed');
+    is($m->value("Time${_}-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');

commit 1609fa01c6863b0fc791ff200e5c0ec102cb57fa
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 0c41491..e150ecf 100755
--- 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 &>
 
@@ -230,8 +230,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 dd4ef2eae02e97bda238fbda5c03e45e9eec42ac
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Aug 3 13:01:27 2011 -0400

    EditTimeValue looks for InputUnits, not InUnits, so pass that instead

diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index e150ecf..08edc4b 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -128,7 +128,7 @@
             args => {
                 Name => 'UpdateTimeWorked',
                 Default => $ARGS{UpdateTimeWorked}||'',
-                InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
+                InputUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
             }
         },
     ]

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


More information about the Rt-commit mailing list