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

Jim Brandt jbrandt at bestpractical.com
Thu Mar 14 16:11:18 EDT 2013


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

- Log -----------------------------------------------------------------
commit 3fe2e825c87b3cecacaabd91eb571cd91ad9d605
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");
 
diff --git a/t/web/admin_queue_lifecycle.t b/t/web/admin_queue_lifecycle.t
index 295e9ea..6b84012 100644
--- a/t/web/admin_queue_lifecycle.t
+++ b/t/web/admin_queue_lifecycle.t
@@ -24,7 +24,7 @@ my $lifecycle_input = $form->find_input('Lifecycle');
 is( $lifecycle_input->value, 'default', 'default lifecycle' );
 
 my @lifecycles = sort $lifecycle_input->possible_values;
-is_deeply( \@lifecycles, [qw/approvals default foo/], 'found all lifecycles' );
+is_deeply( \@lifecycles, [qw/default foo/], 'found all lifecycles' );
 
 $m->submit_form();
 $m->content_lacks( 'Lifecycle changed from',

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


More information about the Rt-commit mailing list