[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-462-g823b340

? sunnavy sunnavy at bestpractical.com
Mon Nov 15 01:33:39 EST 2010


The branch, 3.9-trunk has been updated
       via  823b34096dc9c926b1da524c8de11bf4b4fc54eb (commit)
       via  ee87ddde15ccb4add2d207e347facd09a7a354e3 (commit)
      from  54cd684d002e1ccdf29eaae7d4bdc109144cde1b (commit)

Summary of changes:
 lib/RT/Interface/Web.pm |   12 +++++++++-
 t/web/ticket_owner.t    |   56 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 65 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit ee87ddde15ccb4add2d207e347facd09a7a354e3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Nov 15 14:33:11 2010 +0800

    make action Take or Steal if the actor is the owner

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index d5dd878..13d40dd 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1703,7 +1703,17 @@ sub ProcessTicketBasics {
         my ($ChownType);
         if ( $ARGSRef->{'ForceOwnerChange'} ) {
             $ChownType = "Force";
-        } else {
+        }
+        elsif ( $session{CurrentUser}->id == $ARGSRef->{'Owner'} )
+        {
+            if ( $OrigOwner == RT->Nobody->id ) {
+                $ChownType = "Take";
+            }
+            else {
+                $ChownType = "Steal";
+            }
+        }
+        else {
             $ChownType = "Give";
         }
 

commit 823b34096dc9c926b1da524c8de11bf4b4fc54eb
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Nov 15 14:33:39 2010 +0800

    test for make action Take or Steal if the actor is the owner

diff --git a/t/web/ticket_owner.t b/t/web/ticket_owner.t
index cd1def6..bcac397 100644
--- a/t/web/ticket_owner.t
+++ b/t/web/ticket_owner.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test nodata => 1, tests => 89;
+use RT::Test nodata => 1, tests => 100;
 
 my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
 ok $queue && $queue->id, 'loaded or created queue';
@@ -128,7 +128,7 @@ diag "on reply correct owner is selected";
     is $ticket->Owner, $user_b->id, 'correct owner';
 
     $agent_a->goto_ticket( $id );
-    $agent_a->follow_link_ok({text => 'Reply'}, 'Ticket -> Basics');
+    $agent_a->follow_link_ok({text => 'Reply'}, 'Ticket -> Reply');
 
     my $form = $agent_a->form_name('TicketUpdate');
     is $form->value('Owner'), '', 'empty value selected';
@@ -352,3 +352,55 @@ diag "no Take link when owner is not nobody";
         'but have Steal link');
 }
 
+ok(
+    RT::Test->set_rights(
+        {
+            Principal => $user_a,
+            Right     => [
+                qw(SeeQueue ShowTicket CreateTicket ReplyToTicket OwnTicket TakeTicket StealTicket)
+            ]
+        },
+        { Principal => $user_b, Right => [qw(SeeQueue ShowTicket OwnTicket)] },
+    ),
+    'set rights'
+);
+
+diag "action is Take when old owner is nobody and new owner is current user";
+{ 
+    my $ticket = RT::Ticket->new( $user_a );
+    my ( $id, $txn, $msg ) = $ticket->Create(
+        Queue   => $queue->id,
+        Subject => 'test',
+    );
+    ok $id, 'created a ticket #'. $id or diag "error: $msg";
+    is $ticket->Owner, RT->Nobody->id, 'correct owner';
+
+    $agent_a->goto_ticket( $id );
+    $agent_a->content_lacks('Taken', 'No Taken in display page');
+    $agent_a->follow_link_ok({text => 'Reply'}, 'Ticket -> Reply');
+    $agent_a->form_name('TicketUpdate');
+    $agent_a->select( Owner => $user_a->id );
+    $agent_a->click('SubmitTicket');
+    $agent_a->content_contains('Taken', 'action is Take');
+}
+
+diag "action is Steal when old owner isn't nobody and new owner is current user";
+{ 
+    my $ticket = RT::Ticket->new( $user_a );
+    my ( $id, $txn, $msg ) = $ticket->Create(
+        Queue   => $queue->id,
+        Subject => 'test',
+        Owner => $user_b->id,
+    );
+    ok $id, 'created a ticket #'. $id or diag "error: $msg";
+    is $ticket->Owner, $user_b->id, 'correct owner';
+
+    $agent_a->goto_ticket( $id );
+    $agent_a->content_lacks('Stolen', 'No Stolen in display page');
+    $agent_a->follow_link_ok({text => 'Reply'}, 'Ticket -> Reply');
+    $agent_a->form_name('TicketUpdate');
+    $agent_a->select( Owner => $user_a->id );
+    $agent_a->click('SubmitTicket');
+    $agent_a->content_contains('Stolen from user_b', 'action is Steal');
+}
+

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


More information about the Rt-commit mailing list