[Rt-commit] rt branch, 4.4/shred-cf-txns, created. rt-4.4.2-100-g829a008a5

? sunnavy sunnavy at bestpractical.com
Fri Mar 23 09:42:10 EDT 2018


The branch, 4.4/shred-cf-txns has been created
        at  829a008a53a16c692684b029ebdadb1fb114b242 (commit)

- Log -----------------------------------------------------------------
commit d3e8642b0b9e90233eb62ebdc5e5e11477f729c5
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Mar 23 21:04:44 2018 +0800

    Wipe out related transactions on custom field shred

diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 076b19395..5c3cd8fb8 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -2664,6 +2664,13 @@ sub __DependsOn
     $objs->Limit( FIELD => 'ObjectId', VALUE => $self->id );
     push( @$list, $objs );
 
+    if ( $self->isa( 'RT::CustomField' ) ) {
+        $objs = RT::Transactions->new( $self->CurrentUser );
+        $objs->Limit( FIELD => 'Type',  VALUE => 'CustomField' );
+        $objs->Limit( FIELD => 'Field', VALUE => $self->id );
+        push( @$list, $objs );
+    }
+
 # Links
     if ( $self->can('Links') ) {
         # make sure we don't skip any record

commit 829a008a53a16c692684b029ebdadb1fb114b242
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Mar 23 21:31:18 2018 +0800

    Test transactions on custom field shred

diff --git a/t/shredder/02cfs.t b/t/shredder/02cfs.t
index 94007e88d..30601b206 100644
--- a/t/shredder/02cfs.t
+++ b/t/shredder/02cfs.t
@@ -4,7 +4,7 @@ use warnings;
 
 use Test::Deep;
 use File::Spec;
-use RT::Test::Shredder tests => 5;
+use RT::Test::Shredder tests => undef;
 my $test = "RT::Test::Shredder";
 
 $test->create_savepoint('clean');
@@ -41,3 +41,28 @@ diag 'queue-specific ticket custom field';
     $shredder->WipeoutAll;
     cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
 }
+
+diag 'global ticket custom field + ticket';
+{
+    $test->restore_savepoint('clean');
+    my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket' );
+    $test->create_savepoint('clean_with_ticket');
+
+    my $cf = RT::Test->load_or_create_custom_field(
+        Name       => "Favorite Color",
+        LookupType => "RT::Queue-RT::Ticket",
+        Type       => "FreeformSingle",
+    );
+    my $global_queue = RT::Queue->new(RT->SystemUser);
+    my ($ok, $msg) = $cf->AddToObject($global_queue);
+    ok $ok, "Added ticket CF globally: $msg";
+
+    $ticket->AddCustomFieldValue( Field => $cf->Name, Value => 'foo' );
+
+    my $shredder = $test->shredder_new();
+    $shredder->PutObjects( Objects => $cf );
+    $shredder->WipeoutAll;
+    cmp_deeply( $test->dump_current_and_savepoint('clean_with_ticket'), "current DB equal to savepoint");
+}
+
+done_testing;

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


More information about the rt-commit mailing list