[Rt-commit] rt branch, 4.0/modify-queue-lifecycle-in-admin, created. rt-4.0.4-223-g4f9c258
? sunnavy
sunnavy at bestpractical.com
Sun Jan 22 11:46:23 EST 2012
The branch, 4.0/modify-queue-lifecycle-in-admin has been created
at 4f9c2589ea618550a5dec51db784202ae6958c5f (commit)
- Log -----------------------------------------------------------------
commit ed10a6851c252cde8877e5d83dbf797c5cc7d328
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jan 22 21:33:54 2012 +0800
fix the bug that lifecycle can't set back to "default"
delete lifecycle only if new value is the same as old value.
RT::Record::Update omits undef values, so setting lifecycle to "undef" will be
simply ignored. besides, we don't need to map "default" to undef here, because
RT::Queue::SetLifecycle already does it.
diff --git a/share/html/Admin/Queues/Modify.html b/share/html/Admin/Queues/Modify.html
index 5682eee..b867d3a 100755
--- a/share/html/Admin/Queues/Modify.html
+++ b/share/html/Admin/Queues/Modify.html
@@ -197,10 +197,15 @@ if ( $QueueObj->Id ) {
ARGSRef => \%ARGS,
);
- $ARGS{'Lifecycle'} = undef if defined $ARGS{'Lifecycle'} and $ARGS{'Lifecycle'} eq "default";
+ # avoid the result of "already the current value"
+ delete $ARGS{'Lifecycle'}
+ if $ARGS{'Lifecycle'}
+ && $ARGS{'Lifecycle'} eq
+ ( $QueueObj->_Value('Lifecycle') || 'default' );
+
push @results, UpdateRecordObject(
AttributesRef => \@attribs,
- Object => $QueueObj,
+ Object => $QueueObj,
ARGSRef => \%ARGS
);
commit e7543362b52e3c5e4a8c7cee46f52989a9b9f09f
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jan 22 21:41:48 2012 +0800
tweak result message of SetLifecycle to map undef to "default"
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 3cb87c4..3aca8c2 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -1211,7 +1211,37 @@ sub _Set {
unless ( $self->CurrentUserHasRight('AdminQueue') ) {
return ( 0, $self->loc('Permission Denied') );
}
- return ( $self->SUPER::_Set(@_) );
+
+ my %args = (
+ Field => undef,
+ Value => undef,
+ IsSQL => undef,
+ @_
+ );
+
+ if ( wantarray && $args{Field} && $args{Field} eq 'Lifecycle' ) {
+ my $old_val = $self->__Value($args{'Field'}) || 'default';
+
+ if ( $old_val eq 'default' && !defined $args{Value} ) {
+ return ( 0, $self->loc("That is already the current value") );
+ }
+
+ my ( $status, $msg ) = $self->SUPER::_Set(@_);
+
+ if ($status) {
+ my $new_val = $self->__Value($args{'Field'}) || 'default';
+ $msg = $self->loc(
+ "[_1] changed from [_2] to [_3]",
+ $self->loc( $args{'Field'} ),
+ qq{"$old_val"}, qq{"$new_val"},
+ );
+ }
+ return ( $status, $msg );
+ }
+ else {
+ return $self->SUPER::_Set(@_);
+ }
+
}
commit 4f9c2589ea618550a5dec51db784202ae6958c5f
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jan 22 22:23:50 2012 +0800
test queue's lifecycle change in admin ui
diff --git a/t/web/admin_queue_lifecycle.t b/t/web/admin_queue_lifecycle.t
new file mode 100644
index 0000000..cb18d11
--- /dev/null
+++ b/t/web/admin_queue_lifecycle.t
@@ -0,0 +1,47 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 13;
+
+my $lifecycles = RT->Config->Get('Lifecycles');
+$lifecycles->{foo} = {
+ initial => ['initial'],
+ active => ['open'],
+ inactive => ['resolved'],
+};
+
+RT::Lifecycle->FillCache();
+
+my ( $url, $m ) = RT::Test->started_ok;
+ok( $m->login(), 'logged in' );
+
+$m->get_ok( $url . '/Admin/Queues/Modify.html?id=1' );
+
+my $form = $m->form_name('ModifyQueue');
+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' );
+
+$m->submit_form();
+$m->content_lacks( 'Lifecycle changed from',
+ 'no message of "Lifecycle changed from"' );
+$m->content_lacks( 'That is already the current value',
+ 'no message of "That is already the current value"' );
+
+$form = $m->form_name('ModifyQueue');
+$m->submit_form( fields => { Lifecycle => 'foo' }, );
+$m->content_contains(
+ 'Lifecycle changed from "default" to "foo"');
+$lifecycle_input = $form->find_input('Lifecycle');
+is( $lifecycle_input->value, 'foo', 'lifecycle is changed to foo' );
+
+$form = $m->form_name('ModifyQueue');
+$m->submit_form( fields => { Lifecycle => 'default' }, );
+$m->content_contains(
+ 'Lifecycle changed from "foo" to "default"');
+$lifecycle_input = $form->find_input('Lifecycle');
+is( $lifecycle_input->value, 'default',
+ 'lifecycle is changed back to default' );
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list