[Rt-commit] rt branch, 4.0/forbid-linking-deleted-tickets, updated. rt-4.0.0-194-g6c96238

? sunnavy sunnavy at bestpractical.com
Thu May 12 02:53:12 EDT 2011


The branch, 4.0/forbid-linking-deleted-tickets has been updated
       via  6c96238dee5765ed672ad39a63beb4d60a72e4c7 (commit)
      from  5e3240c8ef340fbe4d593bca01c88766afa8cc96 (commit)

Summary of changes:
 lib/RT/Links.pm    |   13 +++++++++++++
 t/api/link.t       |    4 +++-
 t/ticket/linking.t |    2 +-
 3 files changed, 17 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 6c96238dee5765ed672ad39a63beb4d60a72e4c7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu May 12 14:50:43 2011 +0800

    it's more consistent if Links->Count returns number of valid link too

diff --git a/lib/RT/Links.pm b/lib/RT/Links.pm
index ef81d48..b9617de 100644
--- a/lib/RT/Links.pm
+++ b/lib/RT/Links.pm
@@ -172,6 +172,19 @@ sub ItemsArrayRef {
     return [ grep { $self->IsValidLink($_) } @{ $self->SUPER::ItemsArrayRef } ];
 }
 
+=head2 Count
+
+Returns number of all valid links found in this search.
+
+note: use RedoSearch to flush this instead of _DoCount
+
+=cut
+
+sub Count {
+    my $self = shift;
+    return scalar @{ $self->ItemsArrayRef };
+}
+
 =head2 IsValidLink
 
 if linked to a local ticket and is deleted, then the link is invalid.
diff --git a/t/api/link.t b/t/api/link.t
index 903b587..e4a06fe 100644
--- a/t/api/link.t
+++ b/t/api/link.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test nodata => 1, tests => 87;
+use RT::Test nodata => 1, tests => 88;
 use RT::Test::Web;
 
 use RT::Link;
@@ -235,6 +235,8 @@ ok $cid, 'created a ticket #'. $cid or diag "error: $msg";
     is( @{ $children->ItemsArrayRef },
         0, 'ItemsArrayRef skips deleted tickets' );
 
+    is( $children->Count, 0, 'Count skips deleted tickets' );
+
     # back to active status
     $child->SetStatus('new');
 }
diff --git a/t/ticket/linking.t b/t/ticket/linking.t
index b18340d..3e1554c 100644
--- a/t/ticket/linking.t
+++ b/t/ticket/linking.t
@@ -181,7 +181,7 @@ diag('add link with rights only on base');
     ok($id, $msg);
     is(link_count($filename), 0, "scrips ok");
     $child->CurrentUser( RT->SystemUser );
-    $child->_Links('Base')->_DoCount;
+    $child->_Links('Base')->RedoSearch;
     is($child->_Links('Base')->Count, 0, 'link was deleted');
     RT->Config->Set( StrictLinkACL => 1 );
 }

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


More information about the Rt-commit mailing list