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