[Rt-commit] rt branch, 4.0/display-link-strings-in-transaction-brief-description, created. rt-4.0.9-9-gaed5ba8

Jim Brandt jbrandt at bestpractical.com
Fri Jan 18 16:57:20 EST 2013


The branch, 4.0/display-link-strings-in-transaction-brief-description has been created
        at  aed5ba8a91afc22eab5d7104992a877a75250011 (commit)

- Log -----------------------------------------------------------------
commit cc5efed7f55c53ac2391492db333792a41fb8dd5
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jan 18 16:46:44 2013 -0500

    Tests showing incorrect BriefDescription for link transactions
    
    The BriefDescription subs for AddLink and DeleteLink transactions
    had code to handle a link value that was a string and not a URI,
    but this test shows that the method doesn't return the expected
    string.

diff --git a/t/api/transaction.t b/t/api/transaction.t
new file mode 100644
index 0000000..22c3cfe
--- /dev/null
+++ b/t/api/transaction.t
@@ -0,0 +1,52 @@
+
+use strict;
+use warnings;
+use RT;
+use RT::Test tests => undef;
+use Test::Warn;
+
+use_ok ('RT::Transaction');
+
+{
+    my $u = RT::User->new(RT->SystemUser);
+    $u->Load("root");
+    ok ($u->Id, "Found the root user");
+    ok(my $t = RT::Ticket->new(RT->SystemUser));
+    my ($id, $msg) = $t->Create( Queue => 'General',
+                                    Subject => 'Testing',
+                                    Owner => $u->Id
+                               );
+    ok($id, "Create new ticket $id");
+    isnt($id , 0);
+
+    my $txn = RT::Transaction->new(RT->SystemUser);
+    my ($txn_id, $txn_msg) = $txn->Create(
+                  Type => 'AddLink',
+                  Field => 'RefersTo',
+                  Ticket => $id,
+                  NewValue => 'ticket 42', );
+    ok( $txn_id, "Created transaction $txn_id: $txn_msg");
+
+    my $brief;
+    warning_like { $brief = $txn->BriefDescription }
+                  qr/Could not determine a URI scheme/,
+                    "Caught URI warning";
+
+    is( $brief, 'Reference to ticket 42 added', "Got string description: $brief");
+
+    $txn = RT::Transaction->new(RT->SystemUser);
+    ($txn_id, $txn_msg) = $txn->Create(
+                  Type => 'DeleteLink',
+                  Field => 'RefersTo',
+                  Ticket => $id,
+                  OldValue => 'ticket 42', );
+    ok( $txn_id, "Created transaction $txn_id: $txn_msg");
+
+    warning_like { $brief = $txn->BriefDescription }
+                  qr/Could not determine a URI scheme/,
+                    "Caught URI warning";
+
+    is( $brief, 'Reference to ticket 42 deleted', "Got string description: $brief");
+}
+
+done_testing;

commit aed5ba8a91afc22eab5d7104992a877a75250011
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jan 18 16:50:00 2013 -0500

    Detect non-URI value for BriefDescription on transaction links
    
    The AddLink and DeleteLink subs in BriefDescription relied on
    $URI->Resolver to return false for a non-URI value, but it
    returns the base object which evaluates to true. The FromURI
    call explicitly returns undef if it can't determine the URI scheme
    so use it in the evaluation.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index b5e4dbc..5407542 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -777,8 +777,7 @@ sub BriefDescription {
         my $value;
         if ( $self->NewValue ) {
             my $URI = RT::URI->new( $self->CurrentUser );
-            $URI->FromURI( $self->NewValue );
-            if ( $URI->Resolver ) {
+            if ( $URI->FromURI( $self->NewValue ) ) {
                 $value = $URI->Resolver->AsString;
             }
             else {
@@ -816,8 +815,7 @@ sub BriefDescription {
         my $value;
         if ( $self->OldValue ) {
             my $URI = RT::URI->new( $self->CurrentUser );
-            $URI->FromURI( $self->OldValue );
-            if ( $URI->Resolver ) {
+            if ( $URI->FromURI( $self->OldValue ) ){
                 $value = $URI->Resolver->AsString;
             }
             else {

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


More information about the Rt-commit mailing list