[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-221-gd894a8b

Ruslan Zakirov ruz at bestpractical.com
Wed Sep 5 17:20:18 EDT 2012


The branch, 4.0/apply-scrips-to-multiple-queues has been updated
       via  d894a8b3772fbb2dd842e621d18a7745e799ae1c (commit)
       via  0f86b6838886c90885de59a22beb3090651ba9c1 (commit)
       via  39ea907aaed3417d4d73b4802061412fbbceab59 (commit)
      from  4ebcdba2207f15329b3991bb91091294b5c814b1 (commit)

Summary of changes:
 lib/RT/Handle.pm | 22 +++++++++++++++-------
 lib/RT/Scrip.pm  |  2 ++
 t/api/scrip.t    |  2 +-
 3 files changed, 18 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 39ea907aaed3417d4d73b4802061412fbbceab59
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Sep 6 01:10:10 2012 +0400

    make sure we pass id further, not a string
    
    If caller passes in queue name then we don't complain,
    but later it's INTifyed to zero. We shouldn't let
    this happen.

diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index a38a1dc..d8b7ebb 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -251,6 +251,8 @@ sub AddToObject {
         $queue->Load( $args{'ObjectId'} );
         return (0, $self->loc('Invalid queue'))
             unless $queue->id;
+
+        $args{'ObjectId'} = $queue->id;
     }
     return ( 0, $self->loc('Permission Denied') )
         unless $self->CurrentUser->PrincipalObj->HasRight(

commit 0f86b6838886c90885de59a22beb3090651ba9c1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Sep 6 01:17:08 2012 +0400

    test return value of Disabled for falseness

diff --git a/t/api/scrip.t b/t/api/scrip.t
index c43fb53..7c9bf4a 100644
--- a/t/api/scrip.t
+++ b/t/api/scrip.t
@@ -207,7 +207,7 @@ note 'basic check for disabling scrips';
     ($status, $msg) = $scrip->RemoveFromObject( $queue->id );
     ok($status, 'removed scrip from queue');
 
-    is($scrip->Disabled, undef, "not applied");
+    ok(!$scrip->Disabled, "not applied");
 }
 
 sub check_applications {

commit d894a8b3772fbb2dd842e621d18a7745e799ae1c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Sep 6 01:18:50 2012 +0400

    apply scrip to multiple queues from initialdata
    
    old style was to duplicate scrip in each queue, but
    now we create records in ObjectScrips

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 308f5ba..1ff3861 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1031,14 +1031,22 @@ sub InsertData {
             my @queues = ref $item->{'Queue'} eq 'ARRAY'? @{ $item->{'Queue'} }: $item->{'Queue'} || 0;
             push @queues, 0 unless @queues; # add global queue at least
 
+            my ( $return, $msg ) = $new_entry->Create( %$item, Queue => shift @queues );
+            unless ( $return ) {
+                $RT::Logger->error( $msg );
+                next;
+            }
+            else {
+                $RT::Logger->debug( $return ."." );
+            }
             foreach my $q ( @queues ) {
-                my ( $return, $msg ) = $new_entry->Create( %$item, Queue => $q );
-                unless ( $return ) {
-                    $RT::Logger->error( $msg );
-                }
-                else {
-                    $RT::Logger->debug( $return ."." );
-                }
+                my ($return, $msg) = $new_entry->AddToObject(
+                    ObjectId => $q,
+                    Stage    => $item->{'Stage'},
+                    Disabled => $item->{'Disabled'},
+                );
+                $RT::Logger->error( "Couldn't apply scrip to $q: $msg" )
+                    unless $return;
             }
         }
         $RT::Logger->debug("done.");

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


More information about the Rt-commit mailing list