4 use RT::Test tests => undef;
6 my $queue = RT::Test->load_or_create_queue( Name => 'General' );
8 my $user = RT::Test->load_or_create_user(
10 Password => 'password',
13 my $cf = RT::Test->load_or_create_custom_field( Name => 'test_cf', Queue => $queue->Name, Type => 'FreeformSingle' );
14 my $cf_form_id = 'Object-RT::Ticket--CustomField-'.$cf->Id.'-Value';
15 my $cf_test_value = "some string for test_cf $$";
17 my ( $baseurl, $m ) = RT::Test->started_ok;
20 { Principal => $user, Right => [qw(SeeQueue CreateTicket)] },
21 { Principal => $user, Object => $queue, Right => [qw(SeeCustomField ModifyCustomField)] }
26 ok $m->login( 'user', 'password' ), 'logged in as user';
28 diag "test ShowTicket right";
31 $m->get_ok( '/Ticket/Create.html?Queue=' . $queue->id,
32 'go to ticket create page' );
33 my $form = $m->form_name('TicketCreate');
34 $m->submit_form( fields => { Subject => 'ticket foo', $cf_form_id => $cf_test_value } );
36 my $ticket = RT::Test->last_ticket;
37 ok( $ticket->id, 'ticket is created' );
40 $m->content_lacks( "Ticket $id created", 'created ticket' );
41 $m->content_contains( "No permission to view newly created ticket #$id",
42 'got no permission msg' );
43 $m->warning_like( qr/No permission to view newly created ticket #$id/,
44 'got no permission warning' );
48 $m->content_contains( "No permission to view ticket",
49 'got no permission msg' );
50 $m->warning_like( qr/No permission to view ticket/, 'got warning' );
51 $m->title_is('RT Error');
55 { Principal => $user, Right => [qw(ShowTicket)] },
57 'add ShowTicket right'
62 $m->content_lacks( "No permission to view ticket", 'no error msg' );
63 $m->title_is( "#$id: ticket foo", 'we can it' );
64 $m->content_contains($cf_test_value, "Custom Field was submitted and saved");