[Rt-commit] rt branch, 4.4/serialize-json-initialdata, updated. rt-4.4.1-364-gd2f3c85

Shawn Moore shawn at bestpractical.com
Mon Mar 20 21:26:44 EDT 2017


The branch, 4.4/serialize-json-initialdata has been updated
       via  d2f3c8561acc4d9c7378a9edd8d00109bc7fddc3 (commit)
       via  e1dc40e56078c3186174b54703e766a788f40351 (commit)
       via  0d97984fdc2e79311c5951d0e69ed5e96ef25b66 (commit)
       via  f7de28fa843d8c552b90d096dc7cfe5b33fe2f25 (commit)
       via  ec3220d4ac4e588ce8dfe2704c208368d745cb35 (commit)
       via  59a7716ac45dc6b7a5d858b92f6cd220c403318f (commit)
      from  79a7c65b0fdc6fcb093454eaa37879c15ef9c897 (commit)

Summary of changes:
 lib/RT/Handle.pm                  |  36 ++++--
 lib/RT/Migrate/Serializer/JSON.pm |  31 +++--
 lib/RT/Scrip.pm                   |   7 +-
 t/api/initialdata-roundtrip.t     | 256 ++++++++++++++++++++++++++++++++++++--
 4 files changed, 297 insertions(+), 33 deletions(-)

- Log -----------------------------------------------------------------
commit 59a7716ac45dc6b7a5d858b92f6cd220c403318f
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 21 00:15:44 2017 +0000

    Fail test if there are any unexpected keys
    
    I'd hate to typo "present" and later find that the tests were never
    being run

diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index 96b89ff..225f01e 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -193,6 +193,9 @@ for my $test (@tests) {
             $test->{present}->() if $test->{present};
         });
     };
+
+    delete @$test{qw/name create absent present/};
+    fail("Unexpected keys for test #$id: " . join(', ', sort keys %$test)) if keys %$test;
 }
 
 done_testing();

commit ec3220d4ac4e588ce8dfe2704c208368d745cb35
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 21 00:31:27 2017 +0000

    Scrip tests, fixing up ObjectScrip sort order

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 2011ebd..4d59d54 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1429,6 +1429,7 @@ sub InsertData {
             if (ref($args{Queue})) {
                 # transform ScripObject->Create API into Scrip->Create API
                 $args{Queue}{Queue} = delete $args{Queue}{ObjectId};
+                $args{Queue}{ObjectSortOrder} = delete $args{Queue}{SortOrder};
                 %args = (
                     %args,
                     %{ $args{Queue} },
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 452fd09..7c6089f 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -361,10 +361,11 @@ sub CanonicalizeObjects {
         primary_class      => 'RT::Scrip',
         primary_key        => 'Queue',
         canonicalize_object => sub {
-            my $object = ref($_->{ObjectId})
-                ? $self->_GetSerializedByRef($_->{ObjectId})->{Name}
-                : $_->{ObjectId};
-            return { ObjectId => $object, Stage => $_->{Stage} };
+            my %object = %$_;
+            delete @object{qw/id Scrip Created LastUpdated Creator LastUpdatedBy/};
+            $object{ObjectId} = $self->_GetSerializedByRef($object{ObjectId})->{Name}
+                if $object{ObjectId}; # 0 meaning Global can stay 0
+            return \%object;
         },
     );
 }
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index 9d901ba..46c783f 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -200,9 +200,10 @@ sub Create {
     return ( $id, $msg ) unless $id;
 
     (my $status, $msg) = RT::ObjectScrip->new( $self->CurrentUser )->Add(
-        Scrip    => $self,
-        Stage    => $args{'Stage'},
-        ObjectId => $args{'Queue'},
+        Scrip     => $self,
+        Stage     => $args{'Stage'},
+        ObjectId  => $args{'Queue'},
+        SortOrder => $args{'ObjectSortOrder'},
     );
     $RT::Logger->error( "Couldn't add scrip: $msg" ) unless $status;
 
diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index 225f01e..4cb1879 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -152,6 +152,104 @@ my @tests = (
             ], 'CF values');
         },
     },
+
+    {
+        name => 'Scrips',
+        create => sub {
+            my $bugs = RT::Queue->new(RT->SystemUser);
+            my ($ok, $msg) = $bugs->Create(Name => 'Bugs');
+            ok($ok, $msg);
+
+            my $features = RT::Queue->new(RT->SystemUser);
+            ($ok, $msg) = $features->Create(Name => 'Features');
+            ok($ok, $msg);
+
+            my $disabled = RT::Scrip->new(RT->SystemUser);
+            ($ok, $msg) = $disabled->Create(
+                Queue => 0,
+                Description => 'Disabled Scrip',
+                Template => 'Blank',
+                ScripCondition => 'User Defined',
+                ScripAction => 'User Defined',
+                CustomIsApplicableCode => 'return "condition"',
+                CustomPrepareCode => 'return "prepare"',
+                CustomCommitCode => 'return "commit"',
+            );
+            ok($ok, $msg);
+            $disabled->SetDisabled(1);
+
+            my $stages = RT::Scrip->new(RT->SystemUser);
+            ($ok, $msg) = $stages->Create(
+                Description => 'Staged Scrip',
+                Template => 'Transaction',
+                ScripCondition => 'On Create',
+                ScripAction => 'Notify Owner',
+            );
+            ok($ok, $msg);
+
+            ($ok, $msg) = $stages->RemoveFromObject(0);
+            ok($ok, $msg);
+
+            ($ok, $msg) = $stages->AddToObject(
+                ObjectId  => $bugs->Id,
+                Stage     => 'TransactionBatch',
+                SortOrder => 42,
+            );
+            ok($ok, $msg);
+
+            ($ok, $msg) = $stages->AddToObject(
+                ObjectId  => $features->Id,
+                Stage     => 'TransactionCreate',
+                SortOrder => 99,
+            );
+            ok($ok, $msg);
+        },
+        present => sub {
+            my $bugs = RT::Queue->new(RT->SystemUser);
+            $bugs->Load('Bugs');
+            ok($bugs->Id, 'Bugs queue loaded');
+            is($bugs->Name, 'Bugs');
+
+            my $features = RT::Queue->new(RT->SystemUser);
+            $features->Load('Features');
+            ok($features->Id, 'Features queue loaded');
+            is($features->Name, 'Features');
+
+            my $disabled = RT::Scrip->new(RT->SystemUser);
+            $disabled->LoadByCols(Description => 'Disabled Scrip');
+            ok($disabled->Id, 'Disabled scrip loaded');
+            is($disabled->Description, 'Disabled Scrip', 'Description');
+            is($disabled->Template, 'Blank', 'Template');
+            is($disabled->ConditionObj->Name, 'User Defined', 'Condition');
+            is($disabled->ActionObj->Name, 'User Defined', 'Action');
+            is($disabled->CustomIsApplicableCode, 'return "condition"', 'Condition code');
+            is($disabled->CustomPrepareCode, 'return "prepare"', 'Prepare code');
+            is($disabled->CustomCommitCode, 'return "commit"', 'Commit code');
+            ok($disabled->Disabled, 'Disabled');
+            ok($disabled->IsGlobal, 'IsGlobal');
+
+            my $stages = RT::Scrip->new(RT->SystemUser);
+            $stages->LoadByCols(Description => 'Staged Scrip');
+            ok($stages->Id, 'Staged scrip loaded');
+            is($stages->Description, 'Staged Scrip');
+            ok(!$stages->Disabled, 'not Disabled');
+            ok(!$stages->IsGlobal, 'not Global');
+
+            my $bug_objectscrip = $stages->IsAdded($bugs->Id);
+            ok($bug_objectscrip, 'added to Bugs');
+            is($bug_objectscrip->Stage, 'TransactionBatch', 'Stage');
+            is($bug_objectscrip->SortOrder, 42, 'SortOrder');
+
+            my $features_objectscrip = $stages->IsAdded($features->Id);
+            ok($features_objectscrip, 'added to Features');
+            is($features_objectscrip->Stage, 'TransactionCreate', 'Stage');
+            is($features_objectscrip->SortOrder, 99, 'SortOrder');
+
+            my $general = RT::Queue->new(RT->SystemUser);
+            $general->Load('General');
+            ok(!$stages->IsAdded($general->Id), 'not added to General');
+        },
+    },
 );
 
 my $id = 0;

commit f7de28fa843d8c552b90d096dc7cfe5b33fe2f25
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 21 00:48:06 2017 +0000

    Fail test for unexpected keys sooner
    
    I often start debugging at the first test fail, so I wouldn't even notice
    the problem this test is meant to highlight

diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index 4cb1879..37bf181 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -275,25 +275,28 @@ for my $test (@tests) {
         goto &$warn;
     };
 
-    subtest "$test->{name} (ordinary creation)" => sub {
+    my $name    = delete $test->{name};
+    my $create  = delete $test->{create};
+    my $absent  = delete $test->{absent};
+    my $present = delete $test->{present};
+    fail("Unexpected keys for test #$id ($name): " . join(', ', sort keys %$test)) if keys %$test;
+
+    subtest "$name (ordinary creation)" => sub {
         autorollback(sub {
-            $test->{absent}->() if $test->{absent};
-            $test->{create}->();
-            $test->{present}->() if $test->{present};
+            $absent->() if $absent;
+            $create->();
+            $present->() if $present;
             export_initialdata($directory);
         });
     };
 
-    subtest "$test->{name} (from initialdata)" => sub {
+    subtest "$name (from initialdata)" => sub {
         autorollback(sub {
-            $test->{absent}->() if $test->{absent};
+            $absent->() if $absent;
             import_initialdata($directory);
-            $test->{present}->() if $test->{present};
+            $present->() if $present;
         });
     };
-
-    delete @$test{qw/name create absent present/};
-    fail("Unexpected keys for test #$id: " . join(', ', sort keys %$test)) if keys %$test;
 }
 
 done_testing();

commit 0d97984fdc2e79311c5951d0e69ed5e96ef25b66
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 21 01:08:59 2017 +0000

    Test cleanups

diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index 37bf181..46f9fc0 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -6,6 +6,9 @@ Plugin('RT::Extension::Initialdata::JSON');
 Set($InitialdataFormatHandlers, [ 'perl', 'RT::Extension::Initialdata::JSON' ]);
 CONFIG
 
+my $general = RT::Queue->new(RT->SystemUser);
+$general->Load('General');
+
 my @tests = (
     {
         name => 'Simple user-defined group',
@@ -87,7 +90,7 @@ my @tests = (
             ($ok, $msg) = $cf->Create(
                 Name => 'Fixed In',
                 Type => 'SelectSingle',
-                LookupType => RT::Queue->CustomFieldLookupType,
+                LookupType => RT::Ticket->CustomFieldLookupType,
             );
             ok($ok, $msg);
 
@@ -124,18 +127,15 @@ my @tests = (
 
             my $cf = RT::CustomField->new(RT->SystemUser);
             $cf->Load('Fixed In');
-            ok($cf->Id, 'Features queue loaded');
+            ok($cf->Id, 'Fixed In CF loaded');
             is($cf->Name, 'Fixed In');
             is($cf->Type, 'Select', 'Type');
             is($cf->MaxValues, 1, 'MaxValues');
-            is($cf->LookupType, RT::Queue->CustomFieldLookupType, 'LookupType');
+            is($cf->LookupType, RT::Ticket->CustomFieldLookupType, 'LookupType');
 
             ok($cf->IsAdded($bugs->Id), 'CF is on Bugs queue');
             ok($cf->IsAdded($features->Id), 'CF is on Features queue');
             ok(!$cf->IsAdded(0), 'CF is not global');
-
-            my $general = RT::Queue->new(RT->SystemUser);
-            $general->Load('General');
             ok(!$cf->IsAdded($general->Id), 'CF is not on General queue');
 
             my @values = map { {
@@ -245,8 +245,6 @@ my @tests = (
             is($features_objectscrip->Stage, 'TransactionCreate', 'Stage');
             is($features_objectscrip->SortOrder, 99, 'SortOrder');
 
-            my $general = RT::Queue->new(RT->SystemUser);
-            $general->Load('General');
             ok(!$stages->IsAdded($general->Id), 'not added to General');
         },
     },

commit e1dc40e56078c3186174b54703e766a788f40351
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 21 01:09:44 2017 +0000

    Round-trip unapplied scrips using a NoAutoGlobal key

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 4d59d54..d115809 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1421,8 +1421,16 @@ sub InsertData {
         for my $item (@Scrips) {
             my $new_entry = RT::Scrip->new(RT->SystemUser);
 
-            my @queues = ref $item->{'Queue'} eq 'ARRAY'? @{ $item->{'Queue'} }: $item->{'Queue'} || 0;
-            push @queues, 0 unless @queues; # add global queue at least
+            my @queues = ref $item->{'Queue'} eq 'ARRAY'
+                       ? @{ $item->{'Queue'} }
+                       : ($item->{'Queue'})
+                if $item->{'Queue'};
+
+            if (!@queues) {
+                push @queues, 0 unless $item->{'NoAutoGlobal'};
+            }
+
+            my $remove_global = (delete $item->{'NoAutoGlobal'}) && !@queues;
 
             my %args = %$item;
             $args{Queue} = shift @queues;
@@ -1444,6 +1452,13 @@ sub InsertData {
             else {
                 $RT::Logger->debug( $return ."." );
             }
+
+            if ($remove_global) {
+                my ($return, $msg) = $new_entry->RemoveFromObject(ObjectId => 0);
+                $RT::Logger->error( "Couldn't unapply scrip globally: $msg" )
+                    unless $return;
+            }
+
             foreach my $q ( @queues ) {
                 my %args = (
                     Stage => $item->{'Stage'},
diff --git a/lib/RT/Migrate/Serializer/JSON.pm b/lib/RT/Migrate/Serializer/JSON.pm
index 7c6089f..d8a7e68 100644
--- a/lib/RT/Migrate/Serializer/JSON.pm
+++ b/lib/RT/Migrate/Serializer/JSON.pm
@@ -137,6 +137,15 @@ sub Observe {
     return $self->SUPER::Observe(%args);
 }
 
+sub PushBasics {
+    my $self = shift;
+    $self->SUPER::PushBasics(@_);
+
+    # we want to include all CFs, scrips, etc, not just the reachable ones
+    $self->PushCollections(qw(CustomFields CustomRoles));
+    $self->PushCollections(qw(Scrips)) if $self->{FollowScrips};
+}
+
 sub JSON {
     my $self = shift;
     return $self->{JSON} ||= JSON->new->pretty->canonical;
@@ -227,6 +236,7 @@ sub _CanonicalizeManyToMany {
         object_primary_ref => '',
         primary_class => '',
         primary_key => 'ApplyTo',
+        add_to_primary => undef,
         canonicalize_object => sub { $_->{ObjectId} },
         @_,
     );
@@ -235,6 +245,7 @@ sub _CanonicalizeManyToMany {
     my $object_primary_ref = $args{object_primary_ref};
     my $primary_class = $args{primary_class};
     my $primary_key = $args{primary_key};
+    my %add_to_primary = %{ $args{add_to_primary} || {} };
     my $canonicalize_object = $args{canonicalize_object};
 
     if (my $objects = delete $self->{Records}{$object_class}) {
@@ -248,6 +259,8 @@ sub _CanonicalizeManyToMany {
                 = map &$canonicalize_object,
                   sort { $a->{SortOrder} <=> $b->{SortOrder} }
                   @{ $primary->{$primary_key} || [] };
+
+            %$primary = (%$primary, %add_to_primary);
         }
     }
 }
@@ -356,10 +369,11 @@ sub CanonicalizeObjects {
     );
 
     $self->_CanonicalizeManyToMany(
-        object_class       => 'RT::ObjectScrip',
-        object_primary_ref => 'Scrip',
-        primary_class      => 'RT::Scrip',
-        primary_key        => 'Queue',
+        object_class        => 'RT::ObjectScrip',
+        object_primary_ref  => 'Scrip',
+        primary_class       => 'RT::Scrip',
+        primary_key         => 'Queue',
+        add_to_primary      => { NoAutoGlobal => 1 },
         canonicalize_object => sub {
             my %object = %$_;
             delete @object{qw/id Scrip Created LastUpdated Creator LastUpdatedBy/};
diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index 46f9fc0..4af670f 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -248,6 +248,134 @@ my @tests = (
             ok(!$stages->IsAdded($general->Id), 'not added to General');
         },
     },
+
+    {
+        name => 'Unapplied Objects',
+        create => sub {
+            my $scrip = RT::Scrip->new(RT->SystemUser);
+            my ($ok, $msg) = $scrip->Create(
+                Queue => 0,
+                Description => 'Unapplied Scrip',
+                Template => 'Blank',
+                ScripCondition => 'On Create',
+                ScripAction => 'Notify Owner',
+            );
+            ok($ok, $msg);
+            ($ok, $msg) = $scrip->RemoveFromObject(0);
+            ok($ok, $msg);
+
+            my $cf = RT::CustomField->new(RT->SystemUser);
+            ($ok, $msg) = $cf->Create(
+                Name        => 'Unapplied CF',
+                Type        => 'FreeformSingle',
+                LookupType  => RT::Ticket->CustomFieldLookupType,
+            );
+            ok($ok, $msg);
+
+            my $class = RT::Class->new(RT->SystemUser);
+            ($ok, $msg) = $class->Create(
+                Name => 'Unapplied Class',
+            );
+            ok($ok, $msg);
+
+            my $role = RT::CustomRole->new(RT->SystemUser);
+            ($ok, $msg) = $role->Create(
+                Name => 'Unapplied Custom Role',
+            );
+            ok($ok, $msg);
+        },
+        present => sub {
+            my $scrip = RT::Scrip->new(RT->SystemUser);
+            $scrip->LoadByCols(Description => 'Unapplied Scrip');
+            ok($scrip->Id, 'Unapplied scrip loaded');
+            is($scrip->Description, 'Unapplied Scrip');
+            ok(!$scrip->Disabled, 'not Disabled');
+            ok(!$scrip->IsGlobal, 'not Global');
+            ok(!$scrip->IsAdded($general->Id), 'not applied to General queue');
+
+            my $cf = RT::CustomField->new(RT->SystemUser);
+            $cf->Load('Unapplied CF');
+            ok($cf->Id, 'Unapplied CF loaded');
+            is($cf->Name, 'Unapplied CF');
+            ok(!$cf->Disabled, 'not Disabled');
+            ok(!$cf->IsGlobal, 'not Global');
+            ok(!$cf->IsAdded($general->Id), 'not applied to General queue');
+
+            my $class = RT::Class->new(RT->SystemUser);
+            $class->Load('Unapplied Class');
+            ok($class->Id, 'Unapplied Class loaded');
+            is($class->Name, 'Unapplied Class');
+            ok(!$class->Disabled, 'not Disabled');
+            ok(!$class->IsApplied(0), 'not Global');
+            ok(!$class->IsApplied($general->Id), 'not applied to General queue');
+
+            my $role = RT::CustomRole->new(RT->SystemUser);
+            $role->Load('Unapplied Custom Role');
+            ok($role->Id, 'Unapplied Custom Role loaded');
+            is($role->Name, 'Unapplied Custom Role');
+            ok(!$role->Disabled, 'not Disabled');
+            ok(!$role->IsAdded(0), 'not Global');
+            ok(!$role->IsAdded($general->Id), 'not applied to General queue');
+        },
+    },
+
+    {
+        name => 'Global Objects',
+        create => sub {
+            my $scrip = RT::Scrip->new(RT->SystemUser);
+            my ($ok, $msg) = $scrip->Create(
+                Queue => 0,
+                Description => 'Global Scrip',
+                Template => 'Blank',
+                ScripCondition => 'On Create',
+                ScripAction => 'Notify Owner',
+            );
+            ok($ok, $msg);
+
+            my $cf = RT::CustomField->new(RT->SystemUser);
+            ($ok, $msg) = $cf->Create(
+                Name        => 'Global CF',
+                Type        => 'FreeformSingle',
+                LookupType  => RT::Ticket->CustomFieldLookupType,
+            );
+            ok($ok, $msg);
+            ($ok, $msg) = $cf->AddToObject(RT::Queue->new(RT->SystemUser));
+            ok($ok, $msg);
+
+            my $class = RT::Class->new(RT->SystemUser);
+            ($ok, $msg) = $class->Create(
+                Name => 'Global Class',
+            );
+            ok($ok, $msg);
+            ($ok, $msg) = $class->AddToObject(RT::Queue->new(RT->SystemUser));
+            ok($ok, $msg);
+        },
+        present => sub {
+            my $scrip = RT::Scrip->new(RT->SystemUser);
+            $scrip->LoadByCols(Description => 'Global Scrip');
+            ok($scrip->Id, 'Global scrip loaded');
+            is($scrip->Description, 'Global Scrip');
+            ok(!$scrip->Disabled, 'not Disabled');
+            ok($scrip->IsGlobal, 'Global');
+            ok(!$scrip->IsAdded($general->Id), 'not applied to General queue');
+
+            my $cf = RT::CustomField->new(RT->SystemUser);
+            $cf->Load('Global CF');
+            ok($cf->Id, 'Global CF loaded');
+            is($cf->Name, 'Global CF');
+            ok(!$cf->Disabled, 'not Disabled');
+            ok($cf->IsGlobal, 'Global');
+            ok(!$cf->IsAdded($general->Id), 'not applied to General queue');
+
+            my $class = RT::Class->new(RT->SystemUser);
+            $class->Load('Global Class');
+            ok($class->Id, 'Global Class loaded');
+            is($class->Name, 'Global Class');
+            ok(!$class->Disabled, 'not Disabled');
+            ok($class->IsApplied(0), 'Global');
+            ok(!$class->IsApplied($general->Id), 'not applied to General queue');
+        },
+    },
 );
 
 my $id = 0;

commit d2f3c8561acc4d9c7378a9edd8d00109bc7fddc3
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Mar 21 01:12:36 2017 +0000

    Handle global Class records more consistently in initialdata

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index d115809..445bca9 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1091,19 +1091,21 @@ sub InsertData {
                 $item->{'ApplyTo'} = delete $item->{'Queue'};
             }
 
-            my $apply_to = delete $item->{'ApplyTo'};
+            my $apply_to = (delete $item->{'ApplyTo'}) || 0;
+            $apply_to = [ $apply_to ] unless ref $apply_to;
+
             my $new_entry = RT::Class->new(RT->SystemUser);
             my ( $return, $msg ) = $new_entry->Create(%$item);
             unless ( $return ) {
                 $RT::Logger->error( $msg );
             } else {
                 $RT::Logger->debug( $return ."." );
-                if ( !$apply_to ) {
-                    ( $return, $msg) = $new_entry->AddToObject( RT::Queue->new(RT->SystemUser) );
-                    $RT::Logger->error( $msg ) unless $return;
-                } else {
-                    $apply_to = [ $apply_to ] unless ref $apply_to;
-                    for my $name ( @{ $apply_to } ) {
+
+                for my $name ( @{ $apply_to } ) {
+                    if ( !$name ) {
+                        ( $return, $msg) = $new_entry->AddToObject( RT::Queue->new(RT->SystemUser) );
+                        $RT::Logger->error( $msg ) unless $return;
+                    } else {
                         my $queue = RT::Queue->new( RT->SystemUser );
                         $queue->Load( $name );
                         if ( $queue->id ) {

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


More information about the rt-commit mailing list