4 use RT::Test tests => 38;
5 my ($baseurl, $agent) = RT::Test->started_ok;
7 my $ticket = RT::Ticket->new(RT->SystemUser);
10 Subject => 'Ticket ' . $_,
13 Requestor => 'rss@localhost',
17 ok $agent->login('root', 'password'), 'logged in as root';
19 $agent->get_ok('/Search/Build.html');
20 $agent->form_name('BuildQuery');
21 $agent->field('idOp', '>');
22 $agent->field('ValueOfid', '0');
23 $agent->submit('DoSearch');
24 $agent->follow_link_ok({id => 'page-results'});
27 $agent->content_contains('Ticket ' . $_);
29 my $rdf_path = $agent->uri->path_query;
30 $rdf_path =~ s!Results\.html!Results.rdf!;
32 $agent->follow_link_ok( { text => 'RSS' } );
33 my $noauth_uri = $agent->uri;
34 is( $agent->content_type, 'application/rss+xml', 'content type' );
36 $agent->content_contains('Ticket ' . $_);
38 my $rss_content = $agent->content;
39 $agent->get_ok($rdf_path);
40 is($agent->content, $rss_content, 'old Results.rdf still works');
43 eval { require XML::Simple; };
44 skip 'no XML::Simple found', 6 if $@;
45 my $rss = XML::Simple::XMLin( $rss_content );
46 is( scalar @{ $rss->{item} }, 5, 'item number' );
48 is( $rss->{item}[$_-1]{title}, 'Ticket ' . $_, 'title' . $_ );
53 my $agent_b = RT::Test::Web->new;
54 $agent_b->get_ok($noauth_uri);
55 is( $agent_b->content_type, 'application/rss+xml', 'content type' );
56 is( $agent_b->content, $rss_content, 'content' );
57 $agent_b->get_ok('/', 'back to homepage');
58 $agent_b->content_lacks( 'Logout', 'still not login' );
60 # lets login as another user
61 my $user_b = RT::Test->load_or_create_user(
62 Name => 'user_b', Password => 'password',
64 ok $user_b && $user_b->id, 'loaded or created user';
65 $agent_b->login('user_b', 'password');
66 $agent_b->get_ok($noauth_uri);
67 is( $agent_b->content_type, 'application/rss+xml', 'content type' );
68 is( $agent_b->content, $rss_content, 'content' );
69 $agent_b->get_ok('/', 'back to homepage');
70 $agent_b->content_contains( 'Logout', 'still loggedin' );
71 $agent_b->content_contains( 'user_b', 'still loggedin as user_b' );