summaryrefslogtreecommitdiff
path: root/rt/t/web/search_rss.t
diff options
context:
space:
mode:
Diffstat (limited to 'rt/t/web/search_rss.t')
-rw-r--r--rt/t/web/search_rss.t74
1 files changed, 74 insertions, 0 deletions
diff --git a/rt/t/web/search_rss.t b/rt/t/web/search_rss.t
new file mode 100644
index 0000000..454dc03
--- /dev/null
+++ b/rt/t/web/search_rss.t
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+
+use strict;
+
+use RT::Test tests => 36;
+RT::Test->started_ok;
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+for ( 1 .. 5 ) {
+ $ticket->Create(
+ Subject => 'Ticket ' . $_,
+ Queue => 'General',
+ Owner => 'root',
+ Requestor => 'rss@localhost',
+ );
+}
+
+my $agent = RT::Test::Web->new;
+ok $agent->login('root', 'password'), 'logged in as root';
+
+$agent->get_ok('/Search/Build.html');
+$agent->form_name('BuildQuery');
+$agent->field('idOp', '>');
+$agent->field('ValueOfid', '0');
+$agent->submit('DoSearch');
+$agent->follow_link_ok({text=>'Show Results'});
+
+for ( 1 .. 5 ) {
+ $agent->content_contains('Ticket ' . $_);
+}
+my $rdf_path = $agent->uri->path_query;
+$rdf_path =~ s!Results\.html!Results.rdf!;
+
+$agent->follow_link_ok( { text => 'RSS' } );
+my $noauth_uri = $agent->uri;
+is( $agent->content_type, 'application/rss+xml', 'content type' );
+for ( 1 .. 5 ) {
+ $agent->content_contains('Ticket ' . $_);
+}
+my $rss_content = $agent->content;
+$agent->get_ok($rdf_path);
+is($agent->content, $rss_content, 'old Results.rdf still works');
+
+SKIP: {
+ eval { require XML::Simple; };
+ skip 'no XML::Simple found', 6 if $@;
+ my $rss = XML::Simple::XMLin( $rss_content );
+ is( scalar @{ $rss->{item} }, 5, 'item number' );
+ for ( 1 .. 5 ) {
+ is( $rss->{item}[$_-1]{title}, 'Ticket ' . $_, 'title' . $_ );
+ }
+}
+
+# not login at all
+my $agent_b = RT::Test::Web->new;
+$agent_b->get_ok($noauth_uri);
+is( $agent_b->content_type, 'application/rss+xml', 'content type' );
+is( $agent_b->content, $rss_content, 'content' );
+$agent_b->get_ok('/', 'back to homepage');
+$agent_b->content_lacks( 'Logout', 'still not login' );
+
+# lets login as another user
+my $user_b = RT::Test->load_or_create_user(
+ Name => 'user_b', Password => 'password',
+);
+ok $user_b && $user_b->id, 'loaded or created user';
+$agent_b->login('user_b', 'password'), 'logged in as user B';
+$agent_b->get_ok($noauth_uri);
+is( $agent_b->content_type, 'application/rss+xml', 'content type' );
+is( $agent_b->content, $rss_content, 'content' );
+$agent_b->get_ok('/', 'back to homepage');
+$agent_b->content_contains( 'Logout', 'still loggedin' );
+$agent_b->content_contains( 'user_b', 'still loggedin as user_b' );
+