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 => 'tools-config-queues' } );
20 $m->follow_link_ok( { text => $queue->Name } );
21 $m->follow_link_ok( { id => 'page-scrips-create'});
22 $m->form_name('ModifyScrip');
23 $m->field('Scrip-new-Description' => 'test');
24 $m->select('Scrip-new-ScripCondition' => 'On Transaction');
25 $m->select('Scrip-new-ScripAction' => 'User Defined');
26 $m->select('Scrip-new-Template' => 'Global template: Blank');
27 $m->select('Scrip-new-Stage' => 'TransactionBatch');
28 $m->field('Scrip-new-CustomPrepareCode' => 'return 1;');
29 $m->field('Scrip-new-CustomCommitCode' => 'return 1;');
31 $m->content_contains("Scrip Created");
34 my $form = $m->form_name('ModifyScrip');
35 $sid = $form->value('id');
36 is $m->value("Scrip-$sid-Description"), 'test', 'correct description';
37 is value_name($form, "Scrip-$sid-ScripCondition"), 'On Transaction', 'correct condition';
38 is value_name($form, "Scrip-$sid-ScripAction"), 'User Defined', 'correct action';
39 is value_name($form, "Scrip-$sid-Template"), 'Global template: Blank', 'correct template';
40 is value_name($form, "Scrip-$sid-Stage"), 'TransactionBatch', 'correct stage';
42 my $tmp_fn = File::Spec->catfile( RT::Test->temp_directory, 'transactions' );
43 open my $tmp_fh, '+>', $tmp_fn or die $!;
46 open( my \$fh, '>', '$tmp_fn' ) or die "Couldn't open '$tmp_fn':\$!";
48 my \$batch = \$self->TicketObj->TransactionBatch;
49 unless ( \$batch && \@\$batch ) {
50 print \$fh "no batch\n";
53 foreach my \$txn ( \@\$batch ) {
54 print \$fh \$txn->Type ."\n";
59 $m->field( "Scrip-$sid-CustomCommitCode" => $code );
62 $m->goto_create_ticket( $queue );
63 $m->form_name('TicketCreate');
66 is_deeply parse_handle($tmp_fh), ['Create'], 'Create';
68 $m->follow_link_ok( { text => 'Resolve' } );
69 $m->form_name('TicketUpdate');
70 $m->field( "UpdateContent" => 'resolve it' );
71 $m->click('SubmitTicket');
73 is_deeply parse_handle($tmp_fh), ['Comment', 'Status'], 'Comment + Resolve';
80 my $input = $form->find_input( $field );
82 my @names = $input->value_names;
83 my @values = $input->possible_values;
84 for ( my $i = 0; $i < @values; $i++ ) {
85 return $names[ $i ] if $values[ $i ] eq $input->value;
94 foreach ( @lines ) { s/^\s+//gms; s/\s+$//gms }