[Rt-commit] rt branch, 4.0/display-queue-name-in-set-queue-txn-brief-description, created. rt-4.0.9-16-g19e8d8b
Jim Brandt
jbrandt at bestpractical.com
Wed Jan 23 11:29:21 EST 2013
The branch, 4.0/display-queue-name-in-set-queue-txn-brief-description has been created
at 19e8d8b4bc607ff074840c4fd07d394dc5f9987a (commit)
- Log -----------------------------------------------------------------
commit 9cd3163fdb9c007614a0ac2a04b78ab28a8ca484
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed Jan 23 11:24:17 2013 -0500
Add test for string in set queue txn Brief Description
diff --git a/t/api/transaction.t b/t/api/transaction.t
index 22c3cfe..78ce565 100644
--- a/t/api/transaction.t
+++ b/t/api/transaction.t
@@ -47,6 +47,22 @@ use_ok ('RT::Transaction');
"Caught URI warning";
is( $brief, 'Reference to ticket 42 deleted', "Got string description: $brief");
+
+ my $testqueue = RT::Queue->new(RT->SystemUser);
+ ok( $testqueue->Create( Name => 'My Test Queue'), "Created test queue");
+ like( $testqueue->Id, qr/^\d+$/, "New queue has id: " . $testqueue->Id);
+
+ $txn = RT::Transaction->new(RT->SystemUser);
+ ($txn_id, $txn_msg) = $txn->Create(
+ Type => 'Set',
+ Field => 'Queue',
+ Ticket => $id,
+ OldValue => 'General',
+ NewValue => $testqueue->Id );
+ ok( $txn_id, "Created transaction $txn_id: $txn_msg");
+
+ $brief = $txn->BriefDescription;
+ is( $brief, 'Queue changed from General to My Test Queue', "Got correct brief description: $brief");
}
done_testing;
commit 19e8d8b4bc607ff074840c4fd07d394dc5f9987a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed Jan 23 11:25:43 2013 -0500
Display string for OldValue in set queue txn Brief Description
When a single queue is migrated into a new RT instance, set queue
transactions can't load the queue from OldValue because that queue
isn't available in the current RT instance. Allow BriefDescription
to display a string from OldValue if a queue id isn't provided.
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 5407542..e503d4f 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -868,11 +868,20 @@ sub BriefDescription {
}
elsif ( $self->Field eq 'Queue' ) {
my $q1 = RT::Queue->new( $self->CurrentUser );
- $q1->Load( $self->OldValue );
+ my $old_queue_name;
+ if( $self->OldValue =~ /^\d+$/ ){
+ $q1->Load( $self->OldValue );
+ $old_queue_name = $q1->Name;
+ }
+ else{
+ # Allow string name for migrations where the old queue may
+ # not be available in this instance.
+ $old_queue_name = $self->OldValue;
+ }
my $q2 = RT::Queue->new( $self->CurrentUser );
$q2->Load( $self->NewValue );
return $self->loc("[_1] changed from [_2] to [_3]",
- $self->loc($self->Field) , $q1->Name , $q2->Name);
+ $self->loc($self->Field) , $old_queue_name, $q2->Name);
}
# Write the date/time change at local time:
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list