From 6587f6ba7d047ddc1686c080090afe7d53365bd4 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 24 Apr 2012 11:35:56 -0700 Subject: first pass RT4 merge, RT#13852 --- rt/t/web/transaction_batch.t | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 rt/t/web/transaction_batch.t (limited to 'rt/t/web/transaction_batch.t') diff --git a/rt/t/web/transaction_batch.t b/rt/t/web/transaction_batch.t new file mode 100644 index 000000000..ae04e1fca --- /dev/null +++ b/rt/t/web/transaction_batch.t @@ -0,0 +1,55 @@ +use strict; +use warnings; +use RT; +use RT::Test tests => 12; + + +my $q = RT::Test->load_or_create_queue ( Name => 'General' ); + +my $s1 = RT::Scrip->new(RT->SystemUser); +my ($val, $msg) =$s1->Create( Queue => $q->Id, + ScripCondition => 'User Defined', + ScripAction => 'User Defined', + CustomIsApplicableCode => 'return ($self->TransactionObj->Field||"") eq "TimeEstimated"', + CustomPrepareCode => 'return 1', + CustomCommitCode => '$self->TicketObj->SetPriority($self->TicketObj->Priority + 2); return 1;', + Template => 'Blank', + Stage => 'TransactionBatch', + ); +ok($val,$msg); + +my $ticket = RT::Ticket->new(RT->SystemUser); +my ($tv,$ttv,$tm) = $ticket->Create(Queue => $q->Id, + Subject => "hair on fire", + ); +ok($tv, $tm); + +# Flush the Create transaction off of the ticket +$ticket->ApplyTransactionBatch; + +my $testuser = RT::Test->load_or_create_user( Name => 'bob', EmailAddress => 'bob@example.com', Password => 'password' ); +ok($testuser->Id, "Created test user bob"); + +ok( RT::Test->add_rights({ Principal => 'Privileged', Right => [qw(ShowTicket ModifyTicket SeeQueue)]}), 'Granted ticket management rights'); + +my $test_current_user = RT::CurrentUser->new(); +$test_current_user->LoadByName($testuser->Name); +my $api_test = RT::Ticket->new($test_current_user); +$api_test->Load($ticket->Id); +is($api_test->Priority,0,"Ticket priority starts at 0"); +$api_test->SetTimeEstimated(12); +$api_test->ApplyTransactionBatch; +is($api_test->CurrentUser->UserObj->Name, $testuser->Name,"User didn't change running Transaction Batch scrips"); +$api_test->Load($api_test->Id); +is($api_test->Priority,2,"Ticket priority updated"); + +my ($baseurl, $m) = RT::Test->started_ok; +$m->login('bob','password'); +$m->get_ok("$baseurl/Ticket/Modify.html?id=".$ticket->Id); + $m->submit_form( form_name => 'TicketModify', + fields => { TimeEstimated => 5 } + ); + + +$ticket->Load($ticket->Id); +is ($ticket->Priority , 4, "Ticket priority is set right"); -- cgit v1.2.1