5 use RT::Test tests => 19;
9 my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
10 ok $queue && $queue->id, 'loaded or created queue';
12 RT->Config->Set( UseTransactionBatch => 1 );
14 my ($baseurl, $m) = RT::Test->started_ok;
15 ok $m->login, 'logged in as root';
19 $m->follow_link_ok( { id => 'admin-queues' } );
20 $m->follow_link_ok( { text => $queue->Name } );
21 $m->follow_link_ok( { id => 'page-scrips-create'});
23 $m->form_name('CreateScrip');
24 $m->field('Description' => 'test');
25 $m->select('ScripCondition' => 'On Transaction');
26 $m->select('ScripAction' => 'User Defined');
27 $m->select('Template' => 'Blank');
28 $m->select('Stage' => 'Batch');
29 $m->field('CustomPrepareCode' => 'return 1;');
30 $m->field('CustomCommitCode' => 'return 1;');
32 $m->content_contains("Scrip Created");
34 my $form = $m->form_name('ModifyScrip');
35 $sid = $form->value('id');
36 is $m->value("Description"), 'test', 'correct description';
37 is value_name($form, "ScripCondition"), 'On Transaction', 'correct condition';
38 is value_name($form, "ScripAction"), 'User Defined', 'correct action';
39 is value_name($form, "Template"), 'Blank', 'correct template';
42 my $rec = RT::ObjectScrip->new( RT->SystemUser );
43 $rec->LoadByCols( Scrip => $sid, ObjectId => $queue->id );
44 is $rec->Stage, 'TransactionBatch', "correct stage";
47 my $tmp_fn = File::Spec->catfile( RT::Test->temp_directory, 'transactions' );
48 open my $tmp_fh, '+>', $tmp_fn or die $!;
51 open( my \$fh, '>', '$tmp_fn' ) or die "Couldn't open '$tmp_fn':\$!";
53 my \$batch = \$self->TicketObj->TransactionBatch;
54 unless ( \$batch && \@\$batch ) {
55 print \$fh "no batch\n";
58 foreach my \$txn ( \@\$batch ) {
59 print \$fh \$txn->Type ."\n";
64 $m->field( "CustomCommitCode" => $code );
67 $m->goto_create_ticket( $queue );
68 $m->form_name('TicketCreate');
71 is_deeply parse_handle($tmp_fh), ['Create'], 'Create';
73 $m->follow_link_ok( { text => 'Resolve' } );
74 $m->form_name('TicketUpdate');
75 $m->field( "UpdateContent" => 'resolve it' );
76 $m->click('SubmitTicket');
78 is_deeply parse_handle($tmp_fh), ['Comment', 'Status'], 'Comment + Resolve';
85 my $input = $form->find_input( $field );
87 my @names = $input->value_names;
88 my @values = $input->possible_values;
89 for ( my $i = 0; $i < @values; $i++ ) {
90 return $names[ $i ] if $values[ $i ] eq $input->value;
99 foreach ( @lines ) { s/^\s+//gms; s/\s+$//gms }