4 use RT::Test tests => 22;
6 my $user_a = RT::Test->load_or_create_user(
7 Name => 'user_a', Password => 'password',
9 ok $user_a && $user_a->id, 'loaded or created user';
11 my ($baseurl, $m) = RT::Test->started_ok;
13 ok( RT::Test->set_rights(
14 { Principal => $user_a, Right => [qw(ShowConfigTab ShowTemplate ModifyTemplate)] },
17 ok $m->login('user_a', 'password'), 'logged in as user A';
19 # get to the templates screen
20 $m->follow_link( text => 'Admin' );
21 $m->title_is(q{RT Administration}, 'admin screen');
23 $m->follow_link( text => 'Global' );
24 $m->title_is(q{Admin/Global configuration}, 'global admin');
26 $m->follow_link( text => 'Templates' );
27 $m->title_is(q{Modify templates which apply to all queues}, 'global templates');
29 $m->follow_link( text => 'Resolved' ); # template name
30 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
32 # now try changing Type back and forth
33 $m->form_name('ModifyTemplate');
34 is($m->value('Type'), 'Perl');
36 $m->field(Type => 'Simple');
39 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
40 $m->form_name('ModifyTemplate');
41 is($m->value('Type'), 'Simple', 'updated type to simple');
43 $m->field(Type => 'Perl');
46 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
47 $m->form_name('ModifyTemplate');
48 is($m->value('Type'), 'Simple', 'need the ExecuteCode right to update Type to Perl');
49 $m->content_contains('Permission Denied');
51 ok( RT::Test->add_rights(
52 { Principal => $user_a, Right => [qw(ExecuteCode)] },
53 ), 'add ExecuteCode rights');
55 $m->field(Type => 'Perl');
58 $m->title_is(q{Modify template Resolved}, 'modifying the Resolved template');
59 $m->form_name('ModifyTemplate');
60 is($m->value('Type'), 'Perl', 'now that we have ExecuteCode we can update Type to Perl');
62 { # 21152: Each time you save a Template a newline is chopped off the front
63 $m->form_name('ModifyTemplate');
69 local $TODO = "WWW::Mechanize doesn't strip newline following <textarea> tag like browsers do";
70 # this test fails because earlier tests add newlines when using Mech
71 like($content = $m->value('Content'), qr/^Subject: Resolved/, 'got expected Content');
75 $content = "\n\n\n" . $content;
76 $m->field(Content => $content);
79 $m->content_contains('Template Resolved: Content updated');
81 # next submit should not result in an update
82 $m->form_name('ModifyTemplate');
87 local $TODO = "WWW::Mechanize doesn't strip newline following <textarea> tag like browsers do";
88 # this test fails because the template change makes Mech continuously add newlines where browsers dont
89 $m->content_lacks('Template Resolved: Content updated');