[Rt-commit] rt branch, 4.2/cfs-vs-core-fields-in-create-tickets-action, created. rt-4.0.6-489-g734eb9f

Ruslan Zakirov ruz at bestpractical.com
Tue Aug 21 08:21:35 EDT 2012


The branch, 4.2/cfs-vs-core-fields-in-create-tickets-action has been created
        at  734eb9fbaa2b490f46a1898b622cc14d190b0742 (commit)

- Log -----------------------------------------------------------------
commit 734eb9fbaa2b490f46a1898b622cc14d190b0742
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 21 16:16:28 2012 +0400

    show that CreateTickets sets core field and CF
    
    Every field CreateTickets loads is treated as CF, so
    if you have Status CF then it's set with ticket status.
    
    While it's not bad to simply set CF, but we should
    do it only when there is no core field.
    
    See ticket #18145 on http://issues.bestpractical.com

diff --git a/t/ticket/create-action-cf-vs-core.t b/t/ticket/create-action-cf-vs-core.t
new file mode 100644
index 0000000..2ce95f5
--- /dev/null
+++ b/t/ticket/create-action-cf-vs-core.t
@@ -0,0 +1,57 @@
+use strict; use warnings;
+
+use RT::Test tests => 9;
+
+my $cf;
+{
+    my $cf = RT::CustomField->new( RT->SystemUser );
+    my ($id, $msg)=  $cf->Create(
+        Name => 'Status',
+        Queue => '0',
+        Description => 'A Testing custom field',
+        Type=> 'FreeformSingle'
+    );
+    ok($id, 'Global custom field correctly created');
+}
+
+my $queuea = RT::Test->load_or_create_queue( Name => 'A' );
+ok $queuea && $queuea->id;
+
+my $queueb = RT::Test->load_or_create_queue( Name => 'B' );
+ok $queueb && $queueb->id;
+
+my $template;
+{
+    my $content = <<'END';
+===Create-Ticket: approval
+Queue: B
+Status: open
+END
+    $template = RT::Template->new(RT->SystemUser);
+    my ($status, $msg) = $template->Create(
+        Name => "Test",
+        Queue => $queuea->id,
+        Content => $content,
+    );
+    ok $status, "created a ticket";
+
+    my $scrip = RT::Scrip->new( RT->SystemUser );
+    ($status, $msg) = $scrip->Create(
+        Queue => 'A',
+        ScripCondition => 'On Create',
+        ScripAction => 'Create Tickets',
+        Template => $template->Name,
+    );
+    ok $status, "created a scrip";
+}
+
+{
+    my $ticket = RT::Ticket->new( RT->SystemUser );
+    my ($id) = $ticket->Create( Queue => $queuea, Subject => 'test' );
+    ok $id, "created a ticket";
+
+    my $last = RT::Test->last_ticket;
+    isnt $last->id, $id;
+    is $last->FirstCustomFieldValue('Status'), undef;
+    is $last->Status, 'open';
+}
\ No newline at end of file

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


More information about the Rt-commit mailing list