[Rt-commit] rt branch, 4.0/global-cf-in-create-tickets, created. rt-4.0.1rc1-5-g5e02624
? sunnavy
sunnavy at bestpractical.com
Mon May 30 09:11:36 EDT 2011
The branch, 4.0/global-cf-in-create-tickets has been created
at 5e026242a46c4e085e0516e8f2eb6b3a5fd18ce5 (commit)
- Log -----------------------------------------------------------------
commit 5e026242a46c4e085e0516e8f2eb6b3a5fd18ce5
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon May 30 20:15:22 2011 +0800
load global cf if no such cf with that name in queue
diff --git a/lib/RT/Action/CreateTickets.pm b/lib/RT/Action/CreateTickets.pm
index 54f69d5..432bbcd 100644
--- a/lib/RT/Action/CreateTickets.pm
+++ b/lib/RT/Action/CreateTickets.pm
@@ -778,14 +778,17 @@ sub ParseLines {
my $orig_tag = $original_tags{$tag} or next;
if ( $orig_tag =~ /^customfield-?(\d+)$/i ) {
$ticketargs{ "CustomField-" . $1 } = $args{$tag};
- } elsif ( $orig_tag =~ /^(?:customfield|cf)-?(.*)$/i ) {
+ } elsif ( $orig_tag =~ /^(?:customfield|cf)-?(.+)$/i ) {
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->LoadByName( Name => $1, Queue => $ticketargs{Queue} );
+ $cf->LoadByName( Name => $1 ) unless $cf->id;
+ next unless $cf->id;
$ticketargs{ "CustomField-" . $cf->id } = $args{$tag};
} elsif ($orig_tag) {
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->LoadByName( Name => $orig_tag, Queue => $ticketargs{Queue} );
- next unless ($cf->id) ;
+ $cf->LoadByName( Name => $orig_tag ) unless $cf->id;
+ next unless $cf->id;
$ticketargs{ "CustomField-" . $cf->id } = $args{$tag};
}
diff --git a/t/api/action-createtickets.t b/t/api/action-createtickets.t
index 0ed3624..c37e2ed 100644
--- a/t/api/action-createtickets.t
+++ b/t/api/action-createtickets.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use RT;
-use RT::Test tests => 49;
+use RT::Test tests => 54;
{
@@ -14,10 +14,33 @@ use_ok('RT::ScripAction');
use_ok('RT::ScripCondition');
use_ok('RT::Ticket');
+
+use_ok('RT::CustomField');
+
+my $global_cf = RT::CustomField->new($RT::SystemUser);
+my ($id, $msg)= $global_cf->Create( Name => 'GlobalCF',
+ Queue => '0',
+ SortOrder => '1',
+ Description => 'A Testing custom field',
+ Type=> 'SelectSingle');
+ok($id, 'Global custom field correctly created');
+
+
my $approvalsq = RT::Queue->new(RT->SystemUser);
$approvalsq->Create(Name => 'Approvals');
ok ($approvalsq->Id, "Created Approvals test queue");
+my $queue_cf = RT::CustomField->new($RT::SystemUser);
+($id) = $queue_cf->Create(
+ Name => 'QueueCF',
+ Queue => $approvalsq->Id,
+ SortOrder => 2,
+ Description => 'A testing queue-specific custom field',
+ Type => 'SelectSingle',
+);
+ok($id, 'Queue-specific custom field correctly created');
+
+
my $approvals =
'===Create-Ticket: approval
@@ -26,6 +49,8 @@ Type: approval
AdminCc: {join ("\nAdminCc: ", at admins) }
Depended-On-By: {$Tickets{"TOP"}->Id}
Refers-To: TOP
+CustomField-GlobalCF: A Value
+CustomField-QueueCF: Another Value
Subject: Approval for ticket: {$Tickets{"TOP"}->Id} - {$Tickets{"TOP"}->Subject}
Due: {time + 86400}
Content-Type: text/plain
@@ -76,6 +101,10 @@ my $deps = $t->DependsOn;
is ($deps->Count, 1, "The ticket we created depends on one other ticket");
my $dependson= $deps->First->TargetObj;
ok ($dependson->Id, "It depends on a real ticket");
+is ($dependson->FirstCustomFieldValue('GlobalCF'), 'A Value',
+ 'global custom field was set');
+is ($dependson->FirstCustomFieldValue('QueueCF'), 'Another Value',
+ 'queue custom field was set');
unlike ($dependson->Subject, qr/{/, "The subject doesn't have braces in it. that means we're interpreting expressions");
is ($t->ReferredToBy->Count,1, "It's only referred to by one other ticket");
is ($t->ReferredToBy->First->BaseObj->Id,$t->DependsOn->First->TargetObj->Id, "The same ticket that depends on it refers to it.");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list