[Rt-commit] rt branch, 4.2/hide-approvals-lifecycle, created. rt-4.1.6-345-gb97a61b
Jim Brandt
jbrandt at bestpractical.com
Thu Apr 11 15:34:34 EDT 2013
The branch, 4.2/hide-approvals-lifecycle has been created
at b97a61b6e600468a28019b60f032652533538656 (commit)
- Log -----------------------------------------------------------------
commit b97a61b6e600468a28019b60f032652533538656
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..2c30a4a 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 optional parameter for lifecycle types other than tickets.
+ Defaults to 'ticket'.
+
+Returns: A sorted list of available lifecycles.
=cut
@@ -174,6 +180,24 @@ sub List {
my $self = shift;
my $for = shift || 'ticket';
+ return grep { $_ ne 'approvals' } $self->ListAll( $for );
+}
+
+=head2 ListAll
+
+Returns a list of all lifecycles, including approvals.
+
+Takes: An optional 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 $for = shift || 'ticket';
+
$self->FillCache unless keys %LIFECYCLES_CACHE;
return sort grep {$LIFECYCLES_CACHE{$_}{type} eq $for}
diff --git a/t/lifecycles/types.t b/t/lifecycles/types.t
index 047340b..79b0714 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('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