[Rt-commit] rt branch, 4.2/hide-approvals-lifecycle, created. rt-4.1.6-345-g5f13010

Jim Brandt jbrandt at bestpractical.com
Thu Mar 14 15:58:56 EDT 2013


The branch, 4.2/hide-approvals-lifecycle has been created
        at  5f1301039a8c81edacd27b46096dccbc58f6020e (commit)

- Log -----------------------------------------------------------------
commit 5f1301039a8c81edacd27b46096dccbc58f6020e
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Mar 14 15:56:39 2013 -0400

    Hide approvals lifecycle
    
    Hide the approvals lifecycle to prevent users from selecting it
    when creating new queues. It is only meant for use with the special
    ___Approvals queue.
    
    Add a ListAll method to Lifecycles to provide the complete list.

diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 8fa5959..541ddc9 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -166,7 +166,13 @@ sub Load {
 
 =head2 List
 
-Returns sorted list of the lifecycles' names.
+List available lifecycles. This list omits RT's default approvals
+lifecycle.
+
+Takes: An option parameter for lifecycle types other than tickets.
+       Defaults to 'ticket'.
+
+Returns: A sorted list of available lifecycles.
 
 =cut
 
@@ -174,9 +180,30 @@ sub List {
     my $self = shift;
     my $for = shift || 'ticket';
 
+    return grep { $_ ne 'approvals' } $self->ListAll( For => $for );
+}
+
+=head2 ListAll
+
+Returns a list of all lifecycles, including approvals.
+
+Takes: An option parameter for lifecycle types other than tickets.
+       Defaults to 'ticket'.
+
+Returns: A sorted list of all available lifecycles.
+
+=cut
+
+sub ListAll {
+    my $self = shift;
+    my %args = (
+        For => 'ticket',
+        @_
+    );
+
     $self->FillCache unless keys %LIFECYCLES_CACHE;
 
-    return sort grep {$LIFECYCLES_CACHE{$_}{type} eq $for}
+    return sort grep {$LIFECYCLES_CACHE{$_}{type} eq $args{'For'}}
         grep $_ ne '__maps__', keys %LIFECYCLES_CACHE;
 }
 
diff --git a/t/lifecycles/types.t b/t/lifecycles/types.t
index 047340b..6fb113f 100644
--- a/t/lifecycles/types.t
+++ b/t/lifecycles/types.t
@@ -3,10 +3,14 @@ use warnings;
 
 BEGIN {require  't/lifecycles/utils.pl'};
 
-is_deeply( [ RT::Lifecycle->List], [qw/ approvals default delivery /],
-       "Get the list of lifecycles (implicitly for for tickets)");
-is_deeply( [ RT::Lifecycle->List('ticket') ],  [qw/ approvals default delivery /],
-       "Get the list of lifecycles for tickets");
+is_deeply( [ RT::Lifecycle->ListAll], [qw/ approvals default delivery /],
+       "Get the list of all lifecycles (implicitly for for tickets)");
+is_deeply( [ RT::Lifecycle->ListAll( For => 'ticket') ],  [qw/ approvals default delivery /],
+       "Get the list of all lifecycles for tickets");
+is_deeply( [ RT::Lifecycle->List], [qw/ default delivery /],
+       "Get the list of lifecycles without approvals (implicitly for for tickets)");
+is_deeply( [ RT::Lifecycle->List('ticket') ],  [qw/ default delivery /],
+       "Get the list of lifecycles without approvals for tickets");
 is_deeply( [ RT::Lifecycle->List('racecar') ], [qw/ racing /],
        "Get the list of lifecycles for other types");
 

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


More information about the Rt-commit mailing list