[Rt-commit] rt branch, 4.0/preserve-ticket-basics, repushed
? sunnavy
sunnavy at bestpractical.com
Mon Oct 27 12:38:33 EDT 2014
The branch 4.0/preserve-ticket-basics was deleted and repushed:
was ef01716c1ab5e2f5886133ba6e2e684c0426de05
now 6dfb9a383e7da53f8badf443ab8f951c435c3775
1: c2a9f21 ! 1: 2e8a49c respect InUnits arg so time input won't be converted automatically
@@ -1,52 +1,12 @@
-Author: Jason May <jasonmay at bestpractical.com>
+Author: sunnavy <sunnavy at bestpractical.com>
- Preserve time units (checkpoint)
-
-diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
---- a/lib/RT/Test/Web.pm
-+++ b/lib/RT/Test/Web.pm
-@@
- 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
---- a/share/html/Admin/CustomFields/Objects.html
-+++ b/share/html/Admin/CustomFields/Objects.html
-@@
-
- <& /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 ) {
+ respect InUnits arg so time input won't be converted automatically
+
+ when user inputs "3 hours" worked time on ticket update page, and then clicks
+ "Add More Files": old behavior is to show user "180 minutes", which is kinda
+ surprising and not necessary at all.
+
+ Fixes: #17985
diff --git a/share/html/Elements/EditTimeValue b/share/html/Elements/EditTimeValue
--- a/share/html/Elements/EditTimeValue
@@ -56,30 +16,27 @@
%# END BPS TAGGED BLOCK }}}
<input name="<% $ValueName %>" value="<% $Default || '' %>" size="5" />
-<& /Elements/SelectTimeUnits, Name => $UnitName &>
-+<& /Elements/SelectTimeUnits, Name => $UnitName, Default => $show_units &>
++<& /Elements/SelectTimeUnits, Name => $UnitName, Default => $InUnits &>
<%ARGS>
$Default => ''
$Name => ''
$ValueName => ''
--$UnitName => ''
+ $UnitName => ''
-$InputUnits => 'minutes'
++$InUnits => ''
</%ARGS>
<%INIT>
--$ValueName ||= $Name;
--$UnitName ||= ($Name||$ValueName) . '-TimeUnits';
-+$ValueName ||= $Name;
-+my $UnitName = $ValueName . '-TimeUnits';
+ $ValueName ||= $Name;
+ $UnitName ||= ($Name||$ValueName) . '-TimeUnits';
++$InUnits ||= $m->request_args->{ $UnitName };
++$InUnits ||= RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'}) ? 'hours' : 'minutes';
-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' ) {
++if ($Default && $InUnits eq 'hours') {
+ $Default = sprintf '%.3f', $Default / 60;
-+ $Default =~ s/\.000$//;
++ $Default =~ s!\.000$!!;
}
</%INIT>
@@ -91,11 +48,11 @@
%# 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%>>
++<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%>>
++<option value="hours" <% $Default eq 'hours' ? 'selected="selected"' : '' |n%>>
<% loc('Hours') %>
</option>
</select>
@@ -105,21 +62,12 @@
</%INIT>
<%ARGS>
$Name => ''
-+$Default => 'minutes'
++$Default => RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'}) ? 'hours' : 'minutes'
</%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
-@@
- <& /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>
-
@@
&></td></tr>
<tr><td class="label"><&|/l&>Time Estimated</&>:</td>
@@ -192,93 +140,3 @@
</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
---- /dev/null
-+++ b/t/web/ticket_basics.t
-@@
-+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');
-+ }
-+}
-
2: 19ba149 < -: ------- Preserve time fields in Jumbo by passing the comp args as defaults
3: 63ef97c < -: ------- Use $Action instead of $ARGS{'Action'} to get the 'default value' for free
4: c918c9d < -: ------- Preserve the rest of the ticket basics in Jumbo
5: ef01716 < -: ------- Improve coverage for testing preserved fields on failed CF validation
-: ------- > 2: 7fa49e2 preserve ticket basics in Jumbo
-: ------- > 3: 014d06e goto_update_ticket helper for tests
-: ------- > 4: 6dfb9a3 test preserved tickets basic fields
More information about the rt-commit
mailing list