5 use RT::Test tests => 19;
7 my $user_a = RT::Test->load_or_create_user(
8 Name => 'user_a', Password => 'password',
10 ok $user_a && $user_a->id, 'loaded or created user';
12 my ($baseurl, $m) = RT::Test->started_ok;
14 ok( RT::Test->set_rights(
15 { Principal => $user_a, Right => [qw(ShowConfigTab ShowTemplate ModifyTemplate)] },
18 ok $m->login('user_a', 'password'), 'logged in as user A';
20 # get to the templates screen
21 $m->follow_link( text => 'Configuration' );
22 $m->title_is(q{RT Administration}, 'admin screen');
24 $m->follow_link( text => 'Global' );
25 $m->title_is(q{Admin/Global configuration}, 'global admin');
27 $m->follow_link( text => 'Templates' );
28 $m->title_is(q{Modify templates which apply to all queues}, 'global templates');
30 $m->follow_link( text => 'Resolved' ); # template name
31 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
33 # now try changing Type back and forth
34 $m->form_name('ModifyTemplate');
35 is($m->value('Type'), 'Perl');
37 $m->field(Type => 'Simple');
40 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
41 $m->form_name('ModifyTemplate');
42 is($m->value('Type'), 'Simple', 'updated type to simple');
44 $m->field(Type => 'Perl');
47 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
48 $m->form_name('ModifyTemplate');
49 is($m->value('Type'), 'Simple', 'need the ExecuteCode right to update Type to Perl');
50 $m->content_contains('Permission Denied');
52 ok( RT::Test->add_rights(
53 { Principal => $user_a, Right => [qw(ExecuteCode)] },
54 ), 'add ExecuteCode rights');
56 $m->field(Type => 'Perl');
59 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
60 $m->form_name('ModifyTemplate');
61 is($m->value('Type'), 'Perl', 'now that we have ExecuteCode we can update Type to Perl');