[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.4-73-ge0357e292

? sunnavy sunnavy at bestpractical.com
Wed Oct 23 15:30:33 EDT 2019


The branch, 4.4-trunk has been updated
       via  e0357e292f336e1baf2d01bdf6d9da5a53eff485 (commit)
       via  37b3620a31da790024513bd59d1c889db75c657f (commit)
       via  2bae18b7f5955b948c1c46cd14038a62de38ca59 (commit)
       via  7638ed5205c472f1be0b294cfa7071ed8fd60e52 (commit)
       via  7d5502ffe1a4ee0be0d7854dbfef966c36150f36 (commit)
      from  92bb6103d2de64e6f71a29473bec43323e669959 (commit)

Summary of changes:
 lib/RT/Queue.pm      | 11 ++++-----
 t/shredder/02queue.t | 66 +++++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 63 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit 7638ed5205c472f1be0b294cfa7071ed8fd60e52
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Tue Oct 22 19:48:27 2019 -0500

    Fix test to allow for remaining Scrip

diff --git a/t/shredder/02queue.t b/t/shredder/02queue.t
index 0c65c5daf..04eb5c56d 100644
--- a/t/shredder/02queue.t
+++ b/t/shredder/02queue.t
@@ -22,20 +22,28 @@ diag 'simple queue' if $ENV{TEST_VERBOSE};
 
 diag 'queue with scrip' if $ENV{TEST_VERBOSE};
 {
-    $test->create_savepoint('clean');
-    my $queue = RT::Queue->new( RT->SystemUser );
-    my ($id, $msg) = $queue->Create( Name => 'my queue' );
-    ok($id, 'created queue') or diag "error: $msg";
-
     my $scrip = RT::Scrip->new( RT->SystemUser );
-    ($id, $msg) = $scrip->Create(
+    my ($id, $msg) = $scrip->Create(
         Description    => 'my scrip',
-        Queue          => $queue->id,
         ScripCondition => 'On Create',
         ScripAction    => 'Open Tickets',
         Template       => 'Blank',
     );
     ok($id, 'created scrip') or diag "error: $msg";
+    ok( $scrip->RemoveFromObject(0), 'unapplied scrip from global' );
+
+    # Commit 7d5502ffe makes Scrips not be deleted when a queue is shredded.
+    # we need to create the savepoint before applying the scrip so we can test
+    # to make sure it's remaining after shredding the queue.
+    $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";
+
+    # apply the scrip to the queue.
+    ($id, $msg) = $scrip->AddToObject( ObjectId => $queue->id );
+    ok($id, 'applied scrip to queue') or diag "error: $msg";
 
     my $shredder = $test->shredder_new();
     $shredder->PutObjects( Objects => $queue );

commit 2bae18b7f5955b948c1c46cd14038a62de38ca59
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Oct 23 12:34:33 2019 -0500

    Fix removal of custom fields when shredding queues
    
    Remove the associated ObjectCustomFields entry instead of the CF.

diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index bb7feebe0..f90581932 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -1130,10 +1130,9 @@ sub __DependsOn {
     $objs = $self->Templates;
     push( @$list, $objs );
 
-# Custom Fields
-    $objs = RT::CustomFields->new( $self->CurrentUser );
-    $objs->SetContextObject( $self );
-    $objs->LimitToQueue( $self->id );
+# Object Custom Fields
+    $objs = RT::ObjectCustomFields->new( $self->CurrentUser );
+    $objs->LimitToObjectId( $self->id );
     push( @$list, $objs );
 
 # Object Custom Roles

commit 37b3620a31da790024513bd59d1c889db75c657f
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Wed Oct 23 14:03:07 2019 -0500

    Add tests for shredding queue with custom fields

diff --git a/t/shredder/02queue.t b/t/shredder/02queue.t
index 04eb5c56d..08a1b61a6 100644
--- a/t/shredder/02queue.t
+++ b/t/shredder/02queue.t
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 
 use Test::Deep;
-use RT::Test::Shredder tests => 21;
+use RT::Test::Shredder tests => undef;
 my $test = "RT::Test::Shredder";
 
 diag 'simple queue' if $ENV{TEST_VERBOSE};
@@ -127,3 +127,45 @@ diag 'queue with a watcher' if $ENV{TEST_VERBOSE};
 #    $shredder->WipeoutAll;
 #    cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
 }
+
+diag 'queue with custom fields' if $ENV{TEST_VERBOSE};
+{
+    my $ticket_custom_field = RT::CustomField->new( RT->SystemUser );
+    my ($id, $msg) = $ticket_custom_field->Create(
+        Name => 'ticket custom field',
+        Type => 'Freeform',
+        LookupType => RT::Ticket->CustomFieldLookupType,
+        MaxValues => '1',
+    );
+    ok($id, 'created ticket custom field') or diag "error: $msg";
+
+    my $transaction_custom_field = RT::CustomField->new( RT->SystemUser );
+    ($id, $msg) = $transaction_custom_field->Create(
+        Name => 'transaction custom field',
+        Type => 'Freeform',
+        LookupType => RT::Transaction->CustomFieldLookupType,
+        MaxValues => '1',
+    );
+    ok($id, 'created transaction custom field') 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";
+
+    # apply the custom fields to the queue.
+    ($id, $msg) = $ticket_custom_field->AddToObject( $queue );
+    ok($id, 'applied ticket cf to queue') or diag "error: $msg";
+
+    ($id, $msg) = $transaction_custom_field->AddToObject( $queue );
+    ok($id, 'applied txn cf to queue') or diag "error: $msg";
+
+    my $shredder = $test->shredder_new();
+    $shredder->PutObjects( Objects => $queue );
+    $shredder->WipeoutAll;
+    $test->db_is_valid;
+
+    cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
+}
+
+done_testing;

commit e0357e292f336e1baf2d01bdf6d9da5a53eff485
Merge: 92bb6103d 37b3620a3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Oct 24 03:22:22 2019 +0800

    Merge branch '4.4/fix-shredder-scrip-removal' into 4.4-trunk


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


More information about the rt-commit mailing list