first pass RT4 merge, RT#13852
[freeside.git] / rt / t / web / template.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use RT::Test tests => 19;
6
7 my $user_a = RT::Test->load_or_create_user(
8     Name => 'user_a', Password => 'password',
9 );
10 ok $user_a && $user_a->id, 'loaded or created user';
11
12 my ($baseurl, $m) = RT::Test->started_ok;
13
14 ok( RT::Test->set_rights(
15     { Principal => $user_a, Right => [qw(ShowConfigTab ShowTemplate ModifyTemplate)] },
16 ), 'set rights');
17
18 ok $m->login('user_a', 'password'), 'logged in as user A';
19
20 # get to the templates screen
21 $m->follow_link( text => 'Configuration' );
22 $m->title_is(q{RT Administration}, 'admin screen');
23
24 $m->follow_link( text => 'Global' );
25 $m->title_is(q{Admin/Global configuration}, 'global admin');
26
27 $m->follow_link( text => 'Templates' );
28 $m->title_is(q{Modify templates which apply to all queues}, 'global templates');
29
30 $m->follow_link( text => 'Resolved' ); # template name
31 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
32
33 # now try changing Type back and forth
34 $m->form_name('ModifyTemplate');
35 is($m->value('Type'), 'Perl');
36
37 $m->field(Type => 'Simple');
38 $m->submit;
39
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');
43
44 $m->field(Type => 'Perl');
45 $m->submit;
46
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');
51
52 ok( RT::Test->add_rights(
53     { Principal => $user_a, Right => [qw(ExecuteCode)] },
54 ), 'add ExecuteCode rights');
55
56 $m->field(Type => 'Perl');
57 $m->submit;
58
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');
62