[Rt-commit] rt branch, 4.4/fix-shredder-queue-ocfs, created. rt-4.4.4-75-gcfb1f81c2

? sunnavy sunnavy at bestpractical.com
Thu Oct 24 08:56:59 EDT 2019


The branch, 4.4/fix-shredder-queue-ocfs has been created
        at  cfb1f81c2786d60e9a6a7c5016556b16502b3800 (commit)

- Log -----------------------------------------------------------------
commit b6473b09bb21bb1ff27ad018ed4f0f3319f441dd
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 24 18:51:34 2019 +0800

    Limit ObjectCustomFields LookupType to queue/ticket/txn on queue shredding
    
    LimitObjectId is not enough here, as ocfs is not just for queues, but
    also asset catalogs and article classes.

diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 370e3b9b2..e73d03fc2 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -1135,6 +1135,7 @@ sub __DependsOn {
 # Object Custom Fields
     $objs = RT::ObjectCustomFields->new( $self->CurrentUser );
     $objs->LimitToObjectId( $self->id );
+    $objs->LimitToLookupType( $_ ) for qw/RT::Queue RT::Queue-RT::Ticket RT::Queue-RT::Ticket-RT::Transaction/;
     push( @$list, $objs );
 
 # Object Custom Roles

commit cfb1f81c2786d60e9a6a7c5016556b16502b3800
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 24 20:32:06 2019 +0800

    Test only queue-related ocfs will be shredded on queue shredding
    
    We don't want to shred ocfs of classes and catalogs with the same id.

diff --git a/t/shredder/02queue.t b/t/shredder/02queue.t
index 08a1b61a6..35f347332 100644
--- a/t/shredder/02queue.t
+++ b/t/shredder/02queue.t
@@ -148,10 +148,52 @@ diag 'queue with custom fields' if $ENV{TEST_VERBOSE};
     );
     ok($id, 'created transaction custom field') or diag "error: $msg";
 
+    my $queue_custom_field = RT::CustomField->new( RT->SystemUser );
+    ( $id, $msg ) = $queue_custom_field->Create(
+        Name       => 'queue custom field',
+        Type       => 'Freeform',
+        LookupType => RT::Queue->CustomFieldLookupType,
+        MaxValues  => '1',
+    );
+    ok( $id, 'created queue custom field' ) or diag "error: $msg";
+
+    my $article_custom_field = RT::CustomField->new( RT->SystemUser );
+    ( $id, $msg ) = $article_custom_field->Create(
+        Name       => 'article custom field',
+        Type       => 'Freeform',
+        LookupType => RT::Article->CustomFieldLookupType,
+        MaxValues  => '1',
+    );
+    ok( $id, 'created article custom field' ) or diag "error: $msg";
+
+    my $asset_custom_field = RT::CustomField->new( RT->SystemUser );
+    ( $id, $msg ) = $asset_custom_field->Create(
+        Name       => 'asset custom field',
+        Type       => 'Freeform',
+        LookupType => RT::Catalog->CustomFieldLookupType,
+        MaxValues  => '1',
+    );
+    ok( $id, 'created asset custom field' ) or diag "error: $msg";
+
+    # By default there are 2 queues and 1 class/catalog created.  So we need
+    # to create 1 extra class/catalog to catch up the queue id.
+    my $class = RT::Class->new( RT->SystemUser );
+    ok( $class->Create( Name => "class $_" ), "created class $_" ) for 2 .. 3;
+    is( $class->id, 3, 'Loaded class with the same to-be-created queue id=3' );
+    ( $id, $msg ) = $article_custom_field->AddToObject($class);
+    ok( $id, 'applied article cf to class' ) or diag "error: $msg";
+
+    my $catalog = RT::Catalog->new( RT->SystemUser );
+    ok( $catalog->Create( Name => "catalog $_" ), "created catalog $_" ) for 2 .. 3;
+    is( $catalog->id, 3, 'Loaded catalog with the same to-be-created queue id=3' );
+    ( $id, $msg ) = $asset_custom_field->AddToObject($catalog);
+    ok( $id, 'applied asset cf to catalog' ) or diag "error: $msg";
+
     $test->create_savepoint('clean');
     my $queue = RT::Queue->new( RT->SystemUser );
     ($id, $msg) = $queue->Create( Name => 'my queue' );
     ok($id, 'created queue') or diag "error: $msg";
+    is($id, 3, 'created queue id=3');
 
     # apply the custom fields to the queue.
     ($id, $msg) = $ticket_custom_field->AddToObject( $queue );
@@ -160,6 +202,9 @@ diag 'queue with custom fields' if $ENV{TEST_VERBOSE};
     ($id, $msg) = $transaction_custom_field->AddToObject( $queue );
     ok($id, 'applied txn cf to queue') or diag "error: $msg";
 
+    ( $id, $msg ) = $queue_custom_field->AddToObject($queue);
+    ok( $id, 'applied queue cf to queue' ) or diag "error: $msg";
+
     my $shredder = $test->shredder_new();
     $shredder->PutObjects( Objects => $queue );
     $shredder->WipeoutAll;

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


More information about the rt-commit mailing list