[Rt-commit] rt branch, 4.0/display-queue-name-in-set-queue-txn-brief-description, created. rt-4.0.9-16-g621c427

Jim Brandt jbrandt at bestpractical.com
Thu Jan 24 09:20:04 EST 2013


The branch, 4.0/display-queue-name-in-set-queue-txn-brief-description has been created
        at  621c427c4accb162f4e41881579d82728537d5fb (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 621c427c4accb162f4e41881579d82728537d5fb
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 the queue can't be loaded.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 5407542..2c663b8 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -868,11 +868,19 @@ sub BriefDescription {
         }
         elsif ( $self->Field eq 'Queue' ) {
             my $q1 = RT::Queue->new( $self->CurrentUser );
-            $q1->Load( $self->OldValue );
+            my $old_queue_name;
+            if( $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