[Rt-commit] r8324 - in rt/branches/3.7-EXPERIMENTAL-TUNIS/t: mail web

ruz at bestpractical.com ruz at bestpractical.com
Mon Jul 30 19:25:16 EDT 2007


Author: ruz
Date: Mon Jul 30 19:25:16 2007
New Revision: 8324

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/clicky.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/attachments.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/basic.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_access.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/compilation_errors.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_frontpage.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_search.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/rights.t

Log:
* switch to new API, so all tests are using the same web path

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/clicky.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/clicky.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/clicky.t	Mon Jul 30 19:25:16 2007
@@ -44,12 +44,8 @@
 ok($id, "We created a ticket #$id");
 ok($ticket->Transactions->First->Content, "Has some content");
 
-use constant BaseURL => "http://localhost:".RT->Config->Get('WebPort').RT->Config->Get('WebPath')."/";
-
-$m->get_ok( BaseURL."?user=root;pass=password" );
-$m->content_like(qr/Logout/, 'we did log in');
-
-$m->get_ok( BaseURL."Ticket/Display.html?id=$id" );
+ok $m->login, 'logged in';
+ok $m->goto_ticket($id), 'opened diplay page of the ticket';
 
 SKIP: {
     skip "httpurl action disabled", 1 unless $clicky{'httpurl'};

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t	Mon Jul 30 19:25:16 2007
@@ -58,7 +58,7 @@
 
 use Test::More tests => 152;
 
-use RT::Test;
+use RT::Test config => 'Set( $UnsafeEmailCommands, 1);';
 my ($baseurl, $m) = RT::Test->started_ok;
 
 use RT::Tickets;
@@ -257,8 +257,11 @@
 
 diag "grant everybody with CreateTicket right" if $ENV{'TEST_VERBOSE'};
 {
-    my ($val, $msg) = $everyone_group->PrincipalObj->GrantRight( Right => 'CreateTicket' );
-    ok ($val, "Granted everybody the right to create tickets") or diag "error: $msg";
+    ok( RT::Test->set_rights(
+        { Principal => $everyone_group->PrincipalObj,
+          Right => [qw(CreateTicket)],
+        },
+    ), "Granted everybody the right to create tickets");
 }
 
 my $ticket_id;
@@ -309,8 +312,11 @@
 
 diag "grant everyone 'ReplyToTicket' right" if $ENV{'TEST_VERBOSE'};
 {
-    my ($val,$msg) = $everyone_group->PrincipalObj->GrantRight(Right => 'ReplyToTicket');
-    ok ($val, "Granted everybody the right to reply to  tickets - $msg");
+    ok( RT::Test->set_rights(
+        { Principal => $everyone_group->PrincipalObj,
+          Right => [qw(CreateTicket ReplyToTicket)],
+        },
+    ), "Granted everybody the right to reply to tickets" );
 }
 
 diag "can another random reply to a ticket after being granted privs? answer should be yes" if $ENV{'TEST_VERBOSE'};
@@ -386,8 +392,11 @@
 
 diag "grant everyone 'CommentOnTicket' right" if $ENV{'TEST_VERBOSE'};
 {
-    my ($val,$msg) = $everyone_group->PrincipalObj->GrantRight(Right => 'CommentOnTicket');
-    ok ($val, "Granted everybody the right to reply to  tickets - $msg");
+    ok( RT::Test->set_rights(
+        { Principal => $everyone_group->PrincipalObj,
+          Right => [qw(CreateTicket ReplyToTicket CommentOnTicket)],
+        },
+    ), "Granted everybody the right to comment on tickets");
 }
 
 diag "can another random reply to a ticket after being granted privs? answer should be yes" if $ENV{'TEST_VERBOSE'};

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/attachments.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/attachments.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/attachments.t	Mon Jul 30 19:25:16 2007
@@ -1,19 +1,16 @@
 #!/usr/bin/perl -w
 use strict;
 
-use Test::More tests => 15;
+use Test::More tests => 14;
 use RT::Test;
-my ($baseurl, $m) = RT::Test->started_ok;
 
-my $BaseURL = RT->Config->Get('WebURL');
 use constant LogoFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
 use constant FaviconFile => $RT::MasonComponentRoot .'/NoAuth/images/favicon.png';
 
-my $queue_name = 'General';
-
-$m->get_ok( $BaseURL."?user=root;pass=password" );
-$m->content_like(qr/Logout/, 'we did log in');
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
 
+my $queue_name = 'General';
 my $qid;
 {
     $m->content =~ /<SELECT\s+NAME\s*="Queue"\s*>.*?<OPTION\s+VALUE="(\d+)".*?>\s*\Q$queue_name\E\s*<\/OPTION>/msig;

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/basic.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/basic.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/basic.t	Mon Jul 30 19:25:16 2007
@@ -7,16 +7,12 @@
 use LWP;
 use Encode;
 
-my $cookie_jar = HTTP::Cookies->new;
 use RT::Test;
 my ($baseurl, $agent) = RT::Test->started_ok;
-
-# give the agent a place to stash the cookies
-
-$agent->cookie_jar($cookie_jar);
+$agent->cookie_jar( HTTP::Cookies->new );
 
 # get the top page
-my $url = RT->Config->Get('WebURL');
+my $url = $agent->rt_base_url;
 diag $url;
 $agent->get($url);
 
@@ -76,6 +72,9 @@
 # }}}
 
 # {{{ Query Builder tests
+#
+# XXX: hey-ho, we have these tests in t/web/query-builder
+# TODO: move everything about QB there
 
 my $response = $agent->get($url."Search/Build.html");
 ok( $response->is_success, "Fetched " . $url."Search/Build.html" );

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_access.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_access.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/cf_access.t	Mon Jul 30 19:25:16 2007
@@ -5,7 +5,6 @@
 use RT::Test;
 my ($baseurl, $m) = RT::Test->started_ok;
 
-use constant BaseURL => RT->Config->Get('WebURL');
 use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
 use constant ImageFileContent => do {
     local $/;

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/compilation_errors.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/compilation_errors.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/compilation_errors.t	Mon Jul 30 19:25:16 2007
@@ -17,7 +17,7 @@
 $agent->cookie_jar($cookie_jar);
 
 # get the top page
-my $url = RT->Config->Get('WebURL');
+my $url = $agent->rt_base_url;
 diag "Base URL is '$url'" if $ENV{TEST_VERBOSE};
 $agent->get($url);
 

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_frontpage.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_frontpage.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_frontpage.t	Mon Jul 30 19:25:16 2007
@@ -1,11 +1,11 @@
 #!/usr/bin/perl -w
 use strict;
 
-use Test::More tests => 7;
+use Test::More tests => 6;
 use RT::Test;
 my ($baseurl, $m) = RT::Test->started_ok;
 
-use constant BaseURL => RT->Config->Get('WebURL');
+my $url = $m->rt_base_url;
 
 my $user_obj = RT::User->new($RT::SystemUser);
 my ($ret, $msg) = $user_obj->LoadOrCreateByEmail('customer at example.com');
@@ -18,11 +18,9 @@
 $user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch');
 $user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf');
 
-$m->get( BaseURL."?user=customer;pass=customer" );
+ok $m->login( customer => 'customer' ), "logged in";
 
-$m->content_like(qr/Logout/, 'we did log in');
-
-$m->get ( BaseURL."Search/Build.html");
+$m->get ( $url."Search/Build.html");
 
 #create a saved search
 $m->form_name ('BuildQuery');
@@ -31,25 +29,22 @@
 $m->field ( "SavedSearchDescription" => 'stupid tickets');
 $m->click_button (name => 'SavedSearchSave');
 
-$m->get ( BaseURL.'Prefs/MyRT.html' );
+$m->get ( $url.'Prefs/MyRT.html' );
 $m->content_like (qr/stupid tickets/, 'saved search listed in rt at a glance items');
 
-$m->follow_link (text => 'Logout');
-
-$m->get( BaseURL."?user=root;pass=password" );
-$m->content_like(qr/Logout/, 'we did log in');
+$m->login, 'we did log in as root';
 
-$m->get ( BaseURL.'Prefs/MyRT.html' );
+$m->get ( $url.'Prefs/MyRT.html' );
 $m->form_name ('SelectionBox-body');
 # can't use submit form for mutli-valued select as it uses set_fields
 $m->field ('body-Selected' => ['component-QuickCreate', 'system-Unowned Tickets', 'system-My Tickets']);
 $m->click_button (name => 'remove');
 $m->form_name ('SelectionBox-body');
 #$m->click_button (name => 'body-Save');
-$m->get ( BaseURL );
+$m->get ( $url );
 $m->content_lacks ('highest priority tickets', 'remove everything from body pane');
 
-$m->get ( BaseURL.'Prefs/MyRT.html' );
+$m->get ( $url.'Prefs/MyRT.html' );
 $m->form_name ('SelectionBox-body');
 $m->field ('body-Available' => ['component-QuickCreate', 'system-Unowned Tickets', 'system-My Tickets']);
 $m->click_button (name => 'add');
@@ -63,5 +58,5 @@
 
 $m->form_name ('SelectionBox-body');
 #$m->click_button (name => 'body-Save');
-$m->get ( BaseURL );
+$m->get ( $url );
 $m->content_like (qr'highest priority tickets', 'adds them back');

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_search.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_search.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/custom_search.t	Mon Jul 30 19:25:16 2007
@@ -4,8 +4,7 @@
 use Test::More tests => 10;
 use RT::Test;
 my ($baseurl, $m) = RT::Test->started_ok;
-
-use constant BaseURL => RT->Config->Get('WebURL');
+my $url = $m->rt_base_url;
 
 # reset preferences for easier test?
 
@@ -16,13 +15,13 @@
 	   Owner => 'root', Requestor => 'customsearch at localhost');
 ok(my $id = $t->id, 'created ticket for custom search');
 
-$m->get( BaseURL."?user=root;pass=password" );
-$m->content_like(qr/Logout/, 'we did log in');
+ok $m->login, 'logged in';
+
 my $t_link = $m->find_link( text => "for custom search".$$ );
 like ($t_link->url, qr/$id/, 'link to the ticket we created');
 
 $m->content_lacks ('customsearch at localhost', 'requestor not displayed ');
-$m->get ( BaseURL.'Prefs/MyRT.html' );
+$m->get ( $url.'Prefs/MyRT.html' );
 my $cus_hp = $m->find_link( text => "My Tickets" );
 my $cus_qs = $m->find_link( text => "Quick search" );
 $m->get ($cus_hp);
@@ -37,7 +36,7 @@
 $m->form_name ('BuildQuery');
 $m->click_button (name => 'Save');
 
-$m->get( BaseURL );
+$m->get( $url );
 $m->content_contains ('customsearch at localhost', 'requestor now displayed ');
 
 
@@ -51,7 +50,7 @@
 $m->form_name ('BuildQuery');
 $m->click_button (name => 'Save');
 
-$m->get( BaseURL );
+$m->get( $url );
 $m->content_lacks ('customsearch at localhost', 'requestor not displayed ');
 
 
@@ -67,7 +66,7 @@
 $m->untick('Want-General', '1');
 $m->click_button (name => 'Save');
 
-$m->get( BaseURL );
+$m->get( $url );
 is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
     'General gone from quicksearch list');
 
@@ -77,6 +76,6 @@
 $m->tick('Want-General', '1');
 $m->click_button (name => 'Save');
 
-$m->get( BaseURL );
+$m->get( $url );
 is ($#{$m->find_all_links( text => "General" )}, $nlinks,
     'General back in quicksearch list');

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/rights.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/rights.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/rights.t	Mon Jul 30 19:25:16 2007
@@ -4,11 +4,10 @@
 
 use Test::More tests => 14;
 use RT::Test;
+
 my ($baseurl, $m) = RT::Test->started_ok;
-use constant BaseURL => "http://localhost:".RT->Config->Get('WebPort').RT->Config->Get('WebPath')."/";
+ok $m->login, "logged in";
 
-$m->get( BaseURL."?user=root;pass=password" );
-$m->content_like(qr/Logout/, 'we did log in');
 $m->follow_link_ok({ text => 'Configuration' });
 $m->follow_link_ok({ text => 'Global' });
 $m->follow_link_ok({ text => 'Group Rights' });


More information about the Rt-commit mailing list