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