[Rt-commit] rt branch, 4.6/priority-as-string, created. rt-4.4.4-449-gc74f4d8e5

Michel Rodriguez michel at bestpractical.com
Thu Oct 24 09:57:21 EDT 2019


The branch, 4.6/priority-as-string has been created
        at  c74f4d8e5d37c4c4c799d7123a37a3d722d5ee39 (commit)

- Log -----------------------------------------------------------------
commit fdf7660796f59ae2f74c78b377e89326f88adf96
Author: michel <michel at bestpractical.com>
Date:   Tue Oct 22 16:49:49 2019 +0200

    Cores PriorityAsString
    
    Adds final proposal for the feature:
    
       Set($EnablePriorityAsString, 1);
    
        Set(%PriorityAsString,
          # default (for non specified queues)
          Default => { Low => 0, Medium => 50, High => 100 },
          # per queue priorities
          General    => { Low => 0, High => 1 },
          # drop-downs will display in order Low/High/Medium
          LHM        => [ Low => 0, High => 100, Medium => 50 ],
          # use numerical priorities
          NumQueue   => 0,
        );

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 35b73f5b2..2b86bcde9 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1877,6 +1877,90 @@ Set this to 1 to hide unset fields.
 
 Set($HideUnsetFieldsOnDisplay, 0);
 
+=item C<%EnablePriorityAsString>
+
+Set this to C<0> to disable string priorities and only use
+numerical ones
+
+=cut
+
+Set($EnablePriorityAsString, 1);
+
+=item C<%PriorityAsString>
+
+RT can assign a priority value to tickets. Priority is stored as an
+integer in the database, but RT supports mapping strings to numerical
+values. 
+
+RT supports different priority string mappings for individual queues
+with C<%PriorityAsString>. 
+
+For example, the default mapping is:
+
+    Set(%PriorityAsString,
+      Default => { Low => 0, Medium => 50, High => 100 },
+    )
+
+Use queue names as keys in this hash. 
+
+Values in the hash define the mapping:
+
+=over 4
+
+=item 
+
+C<0> sets the queue to use numerical priorities:
+
+    NumQueue => 0
+
+=item 
+
+a hash C<< { string => numerical_value,... } >> maps each string to
+the numerical value:
+
+    QueueWith3Levels => { Low => 0, Medium => 50, High => 100 }
+
+=item
+
+an array C<< [ string => numerical_value, ... ] >> maps each string to
+the numerical value, and additionaly tells RT to display strings in the
+order they were given in drop-down menus:
+
+      Ordered => [ Low => 0, High => 100, Medium => 50 ]
+    
+In this case the drop-down menus used to choose the priority in RT will
+display Low/High/Medium, in this order
+
+=back
+
+Tickets in queues that aren't defined in this hash will use the mapping
+defined for C<Default>.
+
+A complete exampl of per-queue priority strings:
+
+    Set(%PriorityAsString,
+      # all queues not listed here will use this mapping
+      Default    => { Low => 0, Medium => 50, High => 100 },
+      # 
+      General    => { Low => 0, High => 1 },
+      ColorQueue => { Green => 0, Yellow => 50, Red => 100 },
+      # drop-downs will display in order Low/High/Medium
+      LHM        => [ Low => 0, High => 100, Medium => 50 ],
+      # use numerical priorities
+      NumQueue   => 0,
+    );
+
+Redefine C<%PriorityAsString> in C<RT_SiteConfig.pm> to set site
+priority strings.
+
+The default is 3 levels of priority: Low, Medium and High 
+
+=cut
+
+    Set(%PriorityAsString,
+      Default => { Low => 0, Medium => 50, High => 100 },
+    );
+
 =back
 
 =head2 Group Summary Configuration
diff --git a/etc/RT_SiteConfig.pm b/etc/RT_SiteConfig.pm
deleted file mode 100644
index 9944ebe97..000000000
--- a/etc/RT_SiteConfig.pm
+++ /dev/null
@@ -1,35 +0,0 @@
-use utf8;
-
-# Any configuration directives you include  here will override
-# RT's default configuration file, RT_Config.pm
-#
-# To include a directive here, just copy the equivalent statement
-# from RT_Config.pm and change the value. We've included a single
-# sample value below.
-#
-# If this file includes non-ASCII characters, it must be encoded in
-# UTF-8.
-#
-# This file is actually a perl module, so you can include valid
-# perl code, as well.
-#
-# The converse is also true, if this file isn't valid perl, you're
-# going to run into trouble. To check your SiteConfig file, use
-# this command:
-#
-#   perl -c /path/to/your/etc/RT_SiteConfig.pm
-#
-# You must restart your webserver after making changes to this file.
-#
-
-# You may also split settings into separate files under the etc/RT_SiteConfig.d/
-# directory.  All files ending in ".pm" will be parsed, in alphabetical order,
-# after this file is loaded.
-
-Set( $rtname, 'example.com');
-
-# You must install Plugins on your own, this is only an example
-# of the correct syntax to use when activating them:
-#     Plugin( "RT::Authen::ExternalAuth" );
-
-1;
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index ab42501fd..da747aaf2 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -560,6 +560,14 @@ our %META;
         }
     },
 
+    EnablePriorityAsString => {
+        Widget => '/Widgets/Form/Boolean',
+    },
+    PriorityAsString => {
+        DependsOn => 'EnablePriorityAsString',
+    },
+
+
     # User overridable locale options
     DateTimeFormat => {
         Section         => 'Locale',                       #loc
@@ -1859,6 +1867,113 @@ sub EnableExternalAuth {
     return;
 }
 
+=head2 Methods for specific options
+
+=head2 PriorityMap( <optional_queue_name>)
+
+Returns a hash ref C<< { <priority_as_string> => <priority_value>, ... } >> 
+
+If no queue name is given uses the configuration for C<'Default'>.
+
+If the queue has no C<PriorityAsString> option, uses the one for  C<'Default'>.
+
+Returns C<undef> if C<EnablePriorityAsString> is set to 0, if the
+queue has C<PriorityAsString> switched off (by setting it to C<0>) or if no 
+map is available.
+
+Logs an error if a PriorityAsString is found but it is neither a hash nor an 
+array, nor 0.
+
+=cut
+
+sub PriorityMap
+  { my $self  = shift;
+    my $queue = shift || 'Default';
+
+    my $option = $self->_get_PriorityAsString_for_queue( $queue );
+    return undef if ! $option;
+
+    my $map;
+    if ( ref $option eq 'HASH' ) {
+        # regular map 
+        $map = $option
+    } elsif ( ref $option eq 'ARRAY' ) {
+        # order is irrelevent here, load the array as a hash
+        $map = { @$option };
+    } else {
+        # try to diagnose the problem by showing some details about the map
+        # note: this could also be done when the config is loaded
+
+        # where was the map defined
+        my $queues= $self->Get('PriorityAsString');
+        my $real_queue = defined $queues->{$queue}  ? "queue $queue"
+                       : defined $queues->{Default} ? 'Default queue'
+                       :                              'cannot happen';
+
+        # what's in the map definition 
+        my $option_desc = ref $option         ? "map is a " . ref( $option)
+                        : length $option < 20 ? $option
+                        :                     substr( $option, 0, 17) . '...';
+
+        $RT::Logger->error("Wrong priority map for $real_queue: $option_desc");
+        return undef;
+    }
+    return $map;
+  }
+
+=head2 PriorityMapOrder( <optional_queue_name>)
+
+Returns an array of priority strings, in the proper order for display.
+
+The order is either given in the C<PriorityAsString> option by using an
+array for the queue, or is based on the numerical values of the options
+(lower values first).
+
+=cut
+
+sub PriorityMapOrder
+  { my $self  = shift;
+    my $queue = shift || 'Default';
+
+    my $option = $self->_get_PriorityAsString_for_queue( $queue );
+    return undef if ! $option;
+
+    my @ordered;
+    if ( ref $option eq 'HASH' ) {
+        # hash: sort it on the value
+        @ordered = sort { $option->{$a} <=> $option->{$b} } keys %$option
+    } elsif ( ref $option eq 'ARRAY' ) {
+        # array: use the array order, extract every other element
+        foreach( my $i=0; $i<@$option; $i+=2) {
+            push @ordered, $option->[$i];
+        }
+    } else {
+        return undef;
+    }
+
+    return \@ordered;
+
+  }
+
+# internal method, _get_PriorityAsString_for_queue( <queue name> )
+# returns 
+
+sub _get_PriorityAsString_for_queue
+  { my $self  = shift;
+    my $queue = shift;
+
+    return undef if ! $self->Get( 'EnablePriorityAsString' );
+
+    my $queues = $self->Get( 'PriorityAsString' );
+    return undef if ! $queues;
+
+    my $map = defined $queues->{$queue} ? $queues->{$queue}
+            : defined $queues->{Default}? $queues->{Default}
+            :                             undef;
+
+    return $map;
+  }
+
 RT::Base->_ImportOverlays();
 
 1;
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index dc286a756..783def679 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -1230,6 +1230,11 @@ sub SetDefaultValue {
         },
     );
 
+    if( $args{Name}=~ /^(Initial|Final)Priority/ ) {
+        $old_value= $self->_PriorityAsString( $old_value );
+        $new_value= $self->_PriorityAsString( $new_value );
+    }
+
     if ( $ret ) {
         return ( $ret, $self->loc( 'Default value of [_1] changed from [_2] to [_3]', $args{Name}, $old_value, $new_value ) );
     }
@@ -1238,6 +1243,12 @@ sub SetDefaultValue {
     }
 }
 
+sub _PriorityAsString {
+    my( $self, $priority)= @_;
+    my $map = RT->Config->PriorityMap( $self->Name );
+    return RT::Ticket->_PriorityAsString( $priority, $map );
+}
+
 sub SLA {
     my $self = shift;
     my $value = shift;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 5c400464c..54502bb29 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -2820,10 +2820,18 @@ sub _Set {
     return ( $ret, $msg ) unless $args{'RecordTransaction'};
 
     my $trans;
+
+    my $New= $args{'Value'};
+    # *Priority fields may need to be translated
+    if( $args{'Field'} =~ m{^(Initial|Final)?Priority$}) {
+        $Old= $self->_PriorityAsString( $Old );
+        $New= $self->_PriorityAsString( $New );
+    }
+
     ( $ret, $msg, $trans ) = $self->_NewTransaction(
         Type      => $args{'TransactionType'},
         Field     => $args{'Field'},
-        NewValue  => $args{'Value'},
+        NewValue  => $New,
         OldValue  => $Old,
         TimeTaken => $args{'TimeTaken'},
     );
@@ -3348,7 +3356,9 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 Returns the current value of InitialPriority.
 (In the database, InitialPriority is stored as int(11).)
 
+=head2 InitialPriorityAsString
 
+Returns the current mapped string value of InitialPriority.
 
 =head2 SetInitialPriority VALUE
 
@@ -3366,7 +3376,9 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 Returns the current value of FinalPriority.
 (In the database, FinalPriority is stored as int(11).)
 
+=head2 FinalPriorityAsString
 
+Returns the current mapped string value of FinalPriority.
 
 =head2 SetFinalPriority VALUE
 
@@ -3384,7 +3396,9 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 Returns the current value of Priority.
 (In the database, Priority is stored as int(11).)
 
+=head2 PriorityAsString
 
+Returns the current mapped string value of Priority.
 
 =head2 SetPriority VALUE
 
@@ -3729,6 +3743,49 @@ sub Serialize {
     return %store;
 }
 
+# Returns String: Various Ticket Priorities as either a string or integer
+sub PriorityAsString {
+    my $self = shift;
+    return $self->_PriorityAsString( $self->Priority );
+}
+
+sub InitialPriorityAsString {
+    my $self = shift;
+    return $self->_PriorityAsString( $self->InitialPriority );
+}
+
+sub FinalPriorityAsString {
+    my $self=shift;
+    return $self->_PriorityAsString( $self->FinalPriority );
+}
+
+sub _PriorityAsString {
+    my $self = shift;
+    my $priority = shift;
+    return undef unless defined $priority && length $priority;
+
+    my $map;
+    if( @_ ) {
+        $map = shift;
+    } else {
+        my $queue_name = $self->QueueObj->Name;
+        $map = RT->Config->PriorityMap( $queue_name);
+    }
+
+    return $priority if ! $map;
+
+    my @orderedLabels = sort { $map->{$b} <=> $map->{$a} }  keys %$map;
+
+    # return the label for the first priority <= $priority
+    foreach my $label ( @orderedLabels ) {
+        return $label if $priority >= $map->{ $label };
+    };
+    # if we get here the priority is lower than the lowest in the map
+    # return the label associated with the lowest priority
+    return $orderedLabels[-1];
+
+}
+
 RT::Base->_ImportOverlays();
 
 1;
diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html
index ca8e2d3da..c576f08ed 100644
--- a/share/html/Admin/Queues/DefaultValues.html
+++ b/share/html/Admin/Queues/DefaultValues.html
@@ -59,7 +59,11 @@
       <&|/l&>Priority</&>:
     </div>
     <div class="col-md-9 value">
-      <& /Elements/SelectPriority, Name => "InitialPriority", Default => $queue->DefaultValue('InitialPriority') &>
+      <& /Elements/SelectPriority,
+         Name => "InitialPriority",
+         Default => $queue->DefaultValue('InitialPriority'),
+         QueueObj  => $queue
+      &>
     </div>
   </div>
 
@@ -68,7 +72,11 @@
       <&|/l&>Final Priority</&>:
     </div>
     <div class="col-md-9 value">
-      <& /Elements/SelectPriority, Name => "FinalPriority", Default => $queue->DefaultValue('FinalPriority') &>
+      <& /Elements/SelectPriority,
+         Name => "FinalPriority",
+         Default => $queue->DefaultValue('FinalPriority'),
+         QueueObj  => $queue
+      &>
       <span><em><&|/l&>requires running rt-crontool</&></em></span>
     </div>
   </div>
diff --git a/share/html/Elements/RT__Queue/ColumnMap b/share/html/Elements/RT__Queue/ColumnMap
index 8c902fbe7..16d612aed 100644
--- a/share/html/Elements/RT__Queue/ColumnMap
+++ b/share/html/Elements/RT__Queue/ColumnMap
@@ -67,7 +67,10 @@ my $COLUMN_MAP = {
     },
     Priority => {
         title     => 'Priority', # loc
-        value     => sub { return join '-', $_[0]->DefaultValue('InitialPriority') || '', $_[0]->DefaultValue('FinalPriority') || '' },
+        value     => sub { return join '/', 
+                               map { $_[0]->_PriorityAsString( $_[0]->DefaultValue($_) || 0) }
+                                   qw( InitialPriority FinalPriority); 
+                     },
     },
     DefaultDueIn => {
         title     => 'DefaultDueIn', # loc
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 5f5d4b6b2..3faeac2e7 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -363,6 +363,43 @@ if(RT->Config->Get('DisplayTotalTimeWorked')) {
     }
 }
 
+my $printer = sub {
+    my ($class, $string) = @_;
+    return '' unless defined $string && length $string;
+
+    my $request_path = $HTML::Mason::Commands::r->path_info;
+    if ($request_path and $request_path =~ /Results\.tsv/) {
+        return loc($string);
+    }
+
+    my $escaped = $m->interp->apply_escapes($string, 'h');
+    my $loc_escaped = $m->interp->apply_escapes(loc($string), 'h');
+    return \( qq{<span class="ticket-info-$class-}. lc($escaped) .qq{">$loc_escaped</span>} );
+};
+
+my $queues = RT->Config->Get('PriorityAsString') || {};
+
+foreach my $field (qw(Priority InitialPriority FinalPriority)) {
+    $COLUMN_MAP->{ $field .'Number' } ||= $COLUMN_MAP->{ $field };
+
+    my $class = lc($field);
+    $class =~ s/(?=<.)(?=priority)/-/;
+
+    my $method = $field .'AsString';
+
+    if (not keys %$queues) {
+        $COLUMN_MAP->{ $field }{'value'} = sub {
+            return $printer->( $class, $_[0]->$method() );
+        };
+    } else {
+        $COLUMN_MAP->{ $field }{'value'} = sub {
+            return $queues->{$_[0]->QueueObj->Name}
+                ? $printer->( $class, $_[0]->$method() )
+                : $_[0]->$field;
+        };
+    }
+}
+
 $m->callback( GenericMap => $GenericMap, COLUMN_MAP => $COLUMN_MAP, CallbackName => 'Once', CallbackOnce => 1 );
 return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
 </%init>
diff --git a/share/html/Elements/SelectPriority b/share/html/Elements/SelectPriority
index 2889b4629..c369bc239 100644
--- a/share/html/Elements/SelectPriority
+++ b/share/html/Elements/SelectPriority
@@ -45,11 +45,49 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<input name="<% $Name %>" type="text" value="<% $Default %>" size="5" class="form-control" />
+% if (%map) {
+<select class="select-priority form-control" name="<% $Name %>">
+%     unless ( defined $Default ) {
+<option value="">-</option>
+%     }
+<%PERL>
+foreach my $label ( @order ) {
+    my ($value, $selected);
+    if ( $label eq $default_label ) {
+        ($value, $selected) = ($Default, 'selected="selected"');
+    } else {
+        ($value, $selected) = ($map{ $label }, '');
+    }
+</%PERL>
+<option class="<% lc $label %>" value="<% $value %>" <% $selected |n %>><% loc($label) %></option>
+% }
+</select>
+% } else {
+<input name="<% $Name %>" value="<% $Default %>" size="5" class="form-control" />
+% }
 <%ARGS>
 $Name => 'Priority'
 $Default => ''
+$QueueObj => undef
+$PriorityStringMap => undef
 </%ARGS>
 <%INIT>
+
+my $priority_is_string = undef;
+my @order;
+my $default_label = '';
+my %map = ();
+
+
+if( $QueueObj ) {
+    if( my $map = RT->Config->PriorityMap( $QueueObj->Name ) ) {
+        %map   = %$map;
+        @order = @{RT->Config->PriorityMapOrder( $QueueObj->Name)};
+        if ( defined $Default && length $Default ) {
+        $default_label = RT::Ticket->_PriorityAsString( $Default, \%map ) || '';
+        }
+    }
+}
+
 $Default = '' unless defined $Default;
 </%INIT>
diff --git a/share/html/Search/Elements/PickBasics b/share/html/Search/Elements/PickBasics
index e2a5229d9..87d435eb5 100644
--- a/share/html/Search/Elements/PickBasics
+++ b/share/html/Search/Elements/PickBasics
@@ -236,6 +236,19 @@ my @lines = (
     },
 );
 
+
+if ( RT->Config->Get('EnablePriorityAsString') ) {
+    my ($priority_dropdown) = grep {$_->{Name} eq "Priority"} @lines;
+    my %priority_map = ( '-' => '' );
+    for my $queue (keys %queues) {
+    my $queue_priority_map= RT::Config->PriorityMap( $queue );
+    for my $priority ( keys %$queue_priority_map ) {
+        $priority_map{ keys %queues > 1 ? "$queue: $priority" : "$priority" } = $queue_priority_map->{$priority};
+    }
+    }
+    $priority_dropdown->{Value}{Arguments}{PriorityStringMap} = \%priority_map;
+}
+
 $m->callback( Conditions => \@lines );
 
 </%INIT>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index e65ac52c2..487c36848 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -267,7 +267,8 @@
 <div class="form-row">
   <div class="label col-md-3"><&|/l&>Priority</&>:</div>
   <div class="value col-md-9"><& /Elements/SelectPriority,
-      Name => "InitialPriority",
+    Name => "InitialPriority",
+    QueueObj => $QueueObj,
     Default => $ARGS{InitialPriority} ? $ARGS{InitialPriority} : $QueueObj->DefaultValue('InitialPriority'),
   &></div>
 </div>
@@ -276,6 +277,7 @@
   <div class="label col-md-3"><&|/l&>Final Priority</&>:</div>
   <div class="value col-md-9"><& /Elements/SelectPriority,
     Name => "FinalPriority",
+    QueueObj => $QueueObj,
     Default => $ARGS{FinalPriority} ? $ARGS{FinalPriority} : $QueueObj->DefaultValue('FinalPriority'),
   &></div>
 </div>
diff --git a/share/html/Ticket/Elements/EditBasics b/share/html/Ticket/Elements/EditBasics
index 56171cd43..c8e86a38a 100644
--- a/share/html/Ticket/Elements/EditBasics
+++ b/share/html/Ticket/Elements/EditBasics
@@ -127,6 +127,7 @@ unless ( @fields ) {
                     comp => '/Elements/SelectPriority',
                     args => {
                         Name => $field,
+                        QueueObj => $QueueObj,
                         Default => $defaults{$field} || $TicketObj->$field,
                     }
                 }
diff --git a/share/html/Ticket/Elements/ShowPriority b/share/html/Ticket/Elements/ShowPriority
index 5fb0ad82c..0c8670d04 100644
--- a/share/html/Ticket/Elements/ShowPriority
+++ b/share/html/Ticket/Elements/ShowPriority
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<% $Ticket->Priority %>/<% $Ticket->FinalPriority || ''%>
+<% $Ticket->PriorityAsString %>/<% $Ticket->FinalPriorityAsString || ''%>
 <%ARGS>
 $Ticket => undef
 </%ARGS>
diff --git a/t/web/mobile.t b/t/web/mobile.t
index 3f32e49e6..91d7f3c77 100644
--- a/t/web/mobile.t
+++ b/t/web/mobile.t
@@ -2,6 +2,9 @@ use strict;
 use warnings;
 use RT::Test tests => 170;
 
+# we want to check the numerical priorities
+RT::Config->Set( EnablePriorityAsString => 0);
+
 my ( $url, $m ) = RT::Test->started_ok;
 my $root = RT::Test->load_or_create_user( Name => 'root' );
 

commit c74f4d8e5d37c4c4c799d7123a37a3d722d5ee39
Author: michel <michel at bestpractical.com>
Date:   Wed Oct 23 18:53:15 2019 +0200

    Adds tests and removes a warning
    
    Saving either the default values form for a queue or basics for a ticket
    without changing any value in the form generates an error in the logs.

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 54502bb29..f97b72a19 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -3776,6 +3776,8 @@ sub _PriorityAsString {
 
     my @orderedLabels = sort { $map->{$b} <=> $map->{$a} }  keys %$map;
 
+    # priority could be '(no value)' (or a localized version)
+    $priority = 0 if $priority !~ m{^\d+$};
     # return the label for the first priority <= $priority
     foreach my $label ( @orderedLabels ) {
         return $label if $priority >= $map->{ $label };
diff --git a/share/html/Elements/SelectPriority b/share/html/Elements/SelectPriority
index c369bc239..c011f2a4e 100644
--- a/share/html/Elements/SelectPriority
+++ b/share/html/Elements/SelectPriority
@@ -79,12 +79,12 @@ my $default_label = '';
 my %map = ();
 
 
-if( $QueueObj ) {
+if( $QueueObj and $QueueObj->Id ) {
     if( my $map = RT->Config->PriorityMap( $QueueObj->Name ) ) {
         %map   = %$map;
         @order = @{RT->Config->PriorityMapOrder( $QueueObj->Name)};
         if ( defined $Default && length $Default ) {
-        $default_label = RT::Ticket->_PriorityAsString( $Default, \%map ) || '';
+        $default_label = $QueueObj->_PriorityAsString( $Default);
         }
     }
 }
diff --git a/t/web/queue_create.t b/t/web/queue_create.t
index 40f7b3b8b..680a2ddd9 100644
--- a/t/web/queue_create.t
+++ b/t/web/queue_create.t
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 13;
+use RT::Test tests => 16;
 
 my ( $baseurl, $m ) = RT::Test->started_ok;
 ok $m->login, 'logged in as root';
@@ -69,5 +69,15 @@ diag "Create a queue";
 
     $queue_id = $m->form_name('ModifyQueue')->value('id');
     ok $queue_id, "found id of the queue in the form, it's #$queue_id";
-}
 
+    # Test setting priority
+    $m->follow_link(id => 'page-default-values');
+    $m->content_contains('Final Priority');
+    $m->form_name('ModifyDefaultValues');
+    $m->click_button(value => 'Save Changes');
+    $m->content_contains('Default value of InitialPriority changed');
+    $m->form_name('ModifyDefaultValues');
+    $m->set_fields( FinalPriority => 50);
+    $m->click_button(value => 'Save Changes');
+    $m->content_contains('Default value of FinalPriority changed from Low to Medium');
+}

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


More information about the rt-commit mailing list