6 use RT::Test tests => 7;
9 # {{{ test scrip ordering based on description
11 my $scrip_queue = RT::Queue->new($RT::SystemUser);
12 my ($queue_id, $msg) = $scrip_queue->Create( Name => "ScripOrdering-$$",
13 Description => 'Test scrip ordering by description' );
14 ok($queue_id, "Created scrip-ordering test queue? ".$msg);
16 my $priority_ten_scrip = RT::Scrip->new($RT::SystemUser);
17 (my $id, $msg) = $priority_ten_scrip->Create(
18 Description => "10 set priority $$",
20 ScripCondition => 'On Create',
21 ScripAction => 'User Defined',
22 CustomPrepareCode => '$RT::Logger->debug("Setting priority to 10..."); return 1;',
23 CustomCommitCode => '$self->TicketObj->SetPriority(10);',
25 Stage => 'TransactionCreate',
27 ok($id, "Created priority-10 scrip? ".$msg);
29 my $priority_five_scrip = RT::Scrip->new($RT::SystemUser);
30 ($id, $msg) = $priority_ten_scrip->Create(
31 Description => "05 set priority $$",
33 ScripCondition => 'On Create',
34 ScripAction => 'User Defined',
35 CustomPrepareCode => '$RT::Logger->debug("Setting priority to 5..."); return 1;',
36 CustomCommitCode => '$self->TicketObj->SetPriority(5);',
38 Stage => 'TransactionCreate',
40 ok($id, "Created priority-5 scrip? ".$msg);
42 my $ticket = RT::Ticket->new($RT::SystemUser);
43 ($id, $msg) = $ticket->Create(
45 Requestor => 'order@example.com',
46 Subject => "Scrip order test $$",
48 ok($ticket->id, "Created ticket? id=$id");
50 isnt($ticket->Priority , 0, "Ticket shouldn't be priority 0");
51 isnt($ticket->Priority , 5, "Ticket shouldn't be priority 5");
52 is ($ticket->Priority , 10, "Ticket should be priority 10");