[Rt-commit] rt branch, 4.0/on-forward-conditions, created. rt-4.0.1-197-ga27321a

Jason May jasonmay at bestpractical.com
Fri Jul 29 16:34:04 EDT 2011


The branch, 4.0/on-forward-conditions has been created
        at  a27321ab1a67258ce3dff238b99120c842337b3d (commit)

- Log -----------------------------------------------------------------
commit 6eb92d6b34db19ad3b9a3bc67d71de360f4f33bd
Author: Jason May <jasonmay at bestpractical.com>
Date:   Fri Jul 29 13:54:38 2011 -0400

    Add On Forward * as scrip conditions

diff --git a/etc/initialdata b/etc/initialdata
index 747b77b..3da4a97 100755
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -119,6 +119,27 @@
 
     {
 
+      Name                 => 'On Forward',                                # loc
+      Description          => 'Whenever a ticket or transaction is forwarded', # loc
+      ApplicableTransTypes => 'Forward Transaction,Forward Ticket',
+      ExecModule           => 'AnyTransaction', },
+
+    {
+
+      Name                 => 'On Forward Ticket',                         # loc
+      Description          => 'Whenever a ticket is forwarded',            # loc
+      ApplicableTransTypes => 'Forward Ticket',
+      ExecModule           => 'AnyTransaction', },
+
+    {
+
+      Name                 => 'On Forward Transaction',                    # loc
+      Description          => 'Whenever a transaction is forwarded',       # loc
+      ApplicableTransTypes => 'Forward Transaction',
+      ExecModule           => 'AnyTransaction', },
+
+    {
+
       Name                 => 'On Comment',                                # loc
       Description          => 'Whenever comments come in',                 # loc
       ApplicableTransTypes => 'Comment',

commit a27321ab1a67258ce3dff238b99120c842337b3d
Author: Jason May <jasonmay at bestpractical.com>
Date:   Fri Jul 29 16:32:57 2011 -0400

    Add mech tests for testing On Forward conditions

diff --git a/t/web/scrips.t b/t/web/scrips.t
new file mode 100644
index 0000000..4d141bc
--- /dev/null
+++ b/t/web/scrips.t
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 14;
+
+# TODO:
+# Test the rest of the conditions.
+# Test actions.
+# Test templates?
+# Test cleanup scripts.
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, "logged in";
+
+$m->follow_link_ok({id => 'tools-config-global-scrips-create'});
+
+sub prepare_code_with_value {
+    my $value = shift;
+
+    # changing the ticket is an easy scrip check for a test
+    return
+        '$self->TicketObj->SetSubject(' .
+        '$self->TicketObj->Subject . ' .
+        $value .
+        ')';
+}
+
+{
+    # preserve order for checking the subject string later
+    my @values_for_actions = (
+        [4 => '"Fwd"'],
+        [5 => '"FwdTicket"'],
+        [6 => '"FwdTransaction"'],
+    );
+
+    foreach my $data (@values_for_actions) {
+        my ($condition, $prepare_code_value) = @$data;
+        diag "Create Scrip (Cond #$condition)" if $ENV{TEST_VERBOSE};
+        $m->follow_link_ok({id => 'tools-config-global-scrips-create'});
+        my $prepare_code = prepare_code_with_value($prepare_code_value);
+        $m->form_name('ModifyScrip');
+        $m->set_fields(
+            'Scrip-new-ScripCondition'    => $condition,
+            'Scrip-new-ScripAction'       => 15, # User Defined
+            'Scrip-new-Template'          => 1,  # Blank
+            'Scrip-new-CustomPrepareCode' => $prepare_code,
+        );
+        $m->submit;
+    }
+
+    my $ticket_obj = RT::Test->create_ticket(
+        Subject => 'subject',
+        Content => 'stuff',
+        Queue   => 1,
+    );
+    my $ticket = $ticket_obj->id;
+    $m->get("$baseurl/Ticket/Display.html?id=$ticket");
+
+    $m->follow_link_ok(
+        { id => 'page-actions-forward' },
+        'follow 1st Forward to forward ticket'
+    );
+
+    diag "Forward Ticket" if $ENV{TEST_VERBOSE};
+    $m->submit_form(
+        form_name => 'ForwardMessage',
+        fields    => {
+            To => 'rt-test, rt-to at example.com',
+        },
+        button => 'ForwardAndReturn'
+    );
+
+    $m->text_contains("#${ticket}: subjectFwdFwdTicket");
+
+    diag "Forward Transaction" if $ENV{TEST_VERBOSE};
+    # get the first transaction on the ticket
+    my ($transaction) = $ticket_obj->Transactions->First->id;
+    $m->get(
+        "$baseurl/Ticket/Forward.html?id=1&QuoteTransaction=$transaction"
+    );
+    $m->submit_form(
+        form_name => 'ForwardMessage',
+        fields    => {
+            To => 'rt-test, rt-to at example.com',
+        },
+        button => 'ForwardAndReturn'
+    );
+
+    $m->text_contains("#${ticket}: subjectFwdFwdTicketFwdFwdTransaction");
+
+    RT::Test->clean_caught_mails;
+}

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


More information about the Rt-commit mailing list