default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / rt / t / web / compilation_errors.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use File::Find;
5 BEGIN {
6     sub wanted {
7         -f && /\.html$/ && $_ !~ /Logout.html$/ && $File::Find::dir !~ /RichText/;
8     }
9     my $tests = 7;
10     find( sub { wanted() and $tests += 4 }, 'share/html/' );
11     plan tests => $tests + 1; # plus one for warnings check
12 }
13
14
15 use HTTP::Request::Common;
16 use HTTP::Cookies;
17 use LWP;
18
19 my $cookie_jar = HTTP::Cookies->new;
20
21 use RT::Test;
22 my ($baseurl, $agent) = RT::Test->started_ok;
23
24 # give the agent a place to stash the cookies
25 $agent->cookie_jar($cookie_jar);
26
27 # get the top page
28 my $url = $agent->rt_base_url;
29 $agent->get($url);
30
31 is($agent->status, 200, "Loaded a page");
32
33 # follow the link marked "Login"
34 $agent->login(root => 'password');
35 is($agent->status, 200, "Fetched the page ok");
36 $agent->content_contains('Logout', "Found a logout link");
37
38
39 find ( { wanted => sub { wanted() and test_get($agent, $File::Find::name) }, no_chdir => 1 } , 'share/html/');
40
41 # We expect to spew a lot of warnings; toss them away
42 $agent->get_warnings;
43
44 sub test_get {
45     my $agent = shift;
46         my $file = shift;
47
48         $file =~ s#^share/html/##;
49         diag( "testing $url/$file" );
50
51         $agent->get_ok("$url/$file");
52         is($agent->status, 200, "Loaded $file");
53         $agent->content_lacks('Not logged in', "Still logged in for  $file");
54         $agent->content_lacks('raw error', "Didn't get a Mason compilation error on $file") or do {
55             if (my ($error) = $agent->content =~ /<pre>(.*?line.*?)$/s) {
56                 diag "$file: $error";
57             }
58         };
59 }
60