[Rt-commit] rt branch, admin_ui, updated. 48610699edac8b1cc2c91f0d21ef5336bb9a3fe4
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Dec 31 22:09:08 EST 2009
The branch, admin_ui has been updated
via 48610699edac8b1cc2c91f0d21ef5336bb9a3fe4 (commit)
from 91155149554b281337cc449260ba13b83c5d48fe (commit)
Summary of changes:
t/web/custom_frontpage.t | 85 ++++++++++++++++---------
t/web/custom_search.t | 102 +++++++++++++++++--------------
t/web/rights.t | 154 ++++++++++++++++++++++++++--------------------
3 files changed, 197 insertions(+), 144 deletions(-)
- Log -----------------------------------------------------------------
commit 48610699edac8b1cc2c91f0d21ef5336bb9a3fe4
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jan 1 11:08:55 2010 +0800
skip obsolute tests: we need to refactor it to use new /admin/
diff --git a/t/web/custom_frontpage.t b/t/web/custom_frontpage.t
index 1a57ffd..89e75e1 100644
--- a/t/web/custom_frontpage.t
+++ b/t/web/custom_frontpage.t
@@ -29,34 +29,57 @@ $m->field ( "value_of_attachment" => 'stupid');
$m->field ( "saved_search_description" => 'stupid tickets');
$m->click_button (name => 'saved_search_save');
-$m->get ( $url.'/Prefs/MyRT.html' );
-$m->content_like (qr/stupid tickets/, 'saved search listed in rt at a glance items');
-
-ok $m->login, 'we did log in as root';
-
-$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 ( $url );
-$m->content_lacks ('highest priority tickets', 'remove everything from body pane');
-
-$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');
-
-$m->form_name ('SelectionBox-body');
-$m->field ('body-Selected' => ['component-QuickCreate']);
-$m->click_button (name => 'movedown');
-
-$m->form_name ('SelectionBox-body');
-$m->click_button (name => 'movedown');
-
-$m->form_name ('SelectionBox-body');
-#$m->click_button (name => 'body-Save');
-$m->get ( $url );
-$m->content_like (qr'highest priority tickets', 'adds them back');
+
+SKIP: {
+
+ # use skip instead of todo because the following code will die with todo
+ skip '/Prefs/MyRT.html need to be refactored to use ConfigMyRT action', 4;
+ $m->get( $url . '/Prefs/MyRT.html' );
+ $m->content_like( qr/stupid tickets/,
+ 'saved search listed in rt at a glance items' );
+
+ ok $m->login, 'we did log in as root';
+
+ $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($url);
+ $m->content_lacks( 'highest priority tickets',
+ 'remove everything from body pane' );
+
+ $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' );
+
+ $m->form_name('SelectionBox-body');
+ $m->field( 'body-Selected' => ['component-QuickCreate'] );
+ $m->click_button( name => 'movedown' );
+
+ $m->form_name('SelectionBox-body');
+ $m->click_button( name => 'movedown' );
+
+ $m->form_name('SelectionBox-body');
+
+ #$m->click_button (name => 'body-Save');
+ $m->get($url);
+ $m->content_like( qr'highest priority tickets', 'adds them back' );
+}
diff --git a/t/web/custom_search.t b/t/web/custom_search.t
index 9325258..d2f8c3a 100644
--- a/t/web/custom_search.t
+++ b/t/web/custom_search.t
@@ -20,64 +20,74 @@ 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 ( $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);
-$m->content_like (qr'highest priority tickets');
-# add Requestor to the fields
-$m->form_name('build_query');
-# can't use submit form for mutli-valued select as it uses set_fields
-$m->field (select_display_columns => ['requestors']);
-$m->click_button (name => 'add_col') ;
+SKIP: {
+ # use skip instead of todo because the following code will die with todo
-$m->form_name('build_query');
-$m->click_button (name => 'save');
+ skip '/Prefs/MyRT.html need to be refactored to use ConfigMyRT action', 6;
+ $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);
+ $m->content_like(qr'highest priority tickets');
-$m->get( $url );
-$m->content_contains ('customsearch at localhost', 'requestor now displayed ');
+ # add Requestor to the fields
+ $m->form_name('build_query');
-# now remove Requestor from the fields
-$m->get ($cus_hp);
+ # can't use submit form for mutli-valued select as it uses set_fields
+ $m->field( select_display_columns => ['requestors'] );
+ $m->click_button( name => 'add_col' );
-$m->form_name('build_query');
+ $m->form_name('build_query');
+ $m->click_button( name => 'save' );
-my $cdc = $m->current_form->find_input('current_display_columns');
-my ($requestor_value) = grep { /requestor/ } $cdc->possible_values;
-ok($requestor_value, "got the requestor value");
+ $m->get($url);
+ $m->content_contains( 'customsearch at localhost',
+ 'requestor now displayed ' );
-$m->field (current_display_columns => $requestor_value);
-$m->click_button (name => 'remove_col') ;
+ # now remove Requestor from the fields
+ $m->get($cus_hp);
-$m->form_name('build_query');
-$m->click_button (name => 'save');
+ $m->form_name('build_query');
-$m->get( $url );
-$m->content_lacks ('customsearch at localhost', 'requestor not displayed ');
+ my $cdc = $m->current_form->find_input('current_display_columns');
+ my ($requestor_value) = grep { /requestor/ } $cdc->possible_values;
+ ok( $requestor_value, "got the requestor value" );
+
+ $m->field( current_display_columns => $requestor_value );
+ $m->click_button( name => 'remove_col' );
+
+ $m->form_name('build_query');
+ $m->click_button( name => 'save' );
+ $m->get($url);
+ $m->content_lacks( 'customsearch at localhost', 'requestor not displayed ' );
-# try to disable General from quick search
+ # try to disable General from quick search
-# Note that there's a small problem in the current implementation,
-# since ticked quese are wanted, we do the invesrsion. So any
-# queue added during the quicksearch setting will be unticked.
-my $nlinks = $#{$m->find_all_links( text => "General" )};
-$m->get ($cus_qs);
-$m->form_name('preferences');
-$m->untick('Want-General', '1');
-$m->click_button (name => 'save');
+ # Note that there's a small problem in the current implementation,
+ # since ticked quese are wanted, we do the invesrsion. So any
+ # queue added during the quicksearch setting will be unticked.
+ my $nlinks = $#{ $m->find_all_links( text => "General" ) };
+ $m->get($cus_qs);
+ $m->form_name('preferences');
+ $m->untick( 'Want-General', '1' );
+ $m->click_button( name => 'save' );
-$m->get( $url );
-is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
- 'General gone from quicksearch list');
+ $m->get($url);
+ is(
+ $#{ $m->find_all_links( text => "General" ) },
+ $nlinks - 1,
+ 'General gone from quicksearch list'
+ );
-# get it back
-$m->get ($cus_qs);
-$m->form_name('preferences');
-$m->tick('Want-General', '1');
-$m->click_button (name => 'save');
+ # get it back
+ $m->get($cus_qs);
+ $m->form_name('preferences');
+ $m->tick( 'Want-General', '1' );
+ $m->click_button( name => 'save' );
-$m->get( $url );
-is ($#{$m->find_all_links( text => "General" )}, $nlinks,
- 'General back in quicksearch list');
+ $m->get($url);
+ is( $#{ $m->find_all_links( text => "General" ) },
+ $nlinks, 'General back in quicksearch list' );
+}
diff --git a/t/web/rights.t b/t/web/rights.t
index cf6a256..5b626f3 100644
--- a/t/web/rights.t
+++ b/t/web/rights.t
@@ -7,79 +7,99 @@ use RT::Test strict => 1; use Test::More tests => 14;
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, "logged in";
-$m->follow_link_ok( text => 'Configuration' );
-$m->follow_link_ok( text => 'Global' );
-$m->follow_link_ok( text => 'Group rights' );
-
-
-sub get_rights {
- my $agent = shift;
- my $principal_id = shift;
- my $object = shift;
- $agent->form_name('group_rights_modify');
- my @inputs = $agent->current_form->find_input("revoke_right-$principal_id-$object");
- my @Rights = sort grep $_, map $_->possible_values, grep $_, @inputs;
- return @Rights;
-};
-
-diag "load Everyone group" if $ENV{'TEST_VERBOSE'};
-my ($everyone, $everyone_gid);
-{
- $everyone = RT::Model::Group->new(current_user => RT->system_user );
- $everyone->load_system_internal('Everyone');
- ok($everyone_gid = $everyone->id, "loaded 'everyone' group");
-}
-diag "revoke all global rights from Everyone group" if $ENV{'TEST_VERBOSE'};
-my @has = get_rights( $m, $everyone_gid, 'RT::System-1' );
-if ( @has ) {
- $m->form_name('group_rights_modify');
- $m->tick("revoke_right-$everyone_gid-RT::System-1", $_) foreach @has;
- $m->submit;
-
- is_deeply([get_rights( $m, $everyone_gid, 'RT::System-1' )], [], 'deleted all rights' );
-} else {
- ok(1, 'the group has no global rights');
-}
+SKIP: {
-diag "grant SuperUser right to everyone" if $ENV{'TEST_VERBOSE'};
-{
- $m->form_name('group_rights_modify');
- $m->select("grant_right-$everyone_gid-RT::System-1", ['SuperUser']);
- $m->submit;
+ # TODO: tests new /admin/
+ skip 'should update this for new /admin/', 12;
- $m->content_contains('Right granted', 'got message');
- RT::Model::Principal::invalidate_acl_cache();
- ok($everyone->principal->has_right( right => 'SuperUser', object => RT->system ), 'group has right');
- is_deeply( [get_rights( $m, $everyone_gid, 'RT::System-1' )], ['SuperUser'], 'granted SuperUser right' );
-}
+ $m->follow_link_ok( text => 'Configuration' );
+ $m->follow_link_ok( text => 'Global' );
+ $m->follow_link_ok( text => 'Group rights' );
-diag "revoke the right" if $ENV{'TEST_VERBOSE'};
-{
- $m->form_name('group_rights_modify');
- $m->tick("revoke_right-$everyone_gid-RT::System-1", 'SuperUser');
- $m->submit;
+ sub get_rights {
+ my $agent = shift;
+ my $principal_id = shift;
+ my $object = shift;
+ $agent->form_name('group_rights_modify');
+ my @inputs = $agent->current_form->find_input(
+ "revoke_right-$principal_id-$object");
+ my @Rights = sort grep $_, map $_->possible_values, grep $_, @inputs;
+ return @Rights;
+ }
- $m->content_contains('Right revoked', 'got message');
- RT::Model::Principal::invalidate_acl_cache();
- ok(!$everyone->principal->has_right( right => 'SuperUser', object => RT->system ), 'group has no right');
- is_deeply( [get_rights( $m, $everyone_gid, 'RT::System-1' )], [], 'revoked SuperUser right' );
-}
+ diag "load Everyone group" if $ENV{'TEST_VERBOSE'};
+ my ( $everyone, $everyone_gid );
+ {
+ $everyone = RT::Model::Group->new( current_user => RT->system_user );
+ $everyone->load_system_internal('Everyone');
+ ok( $everyone_gid = $everyone->id, "loaded 'everyone' group" );
+ }
+
+ diag "revoke all global rights from Everyone group" if $ENV{'TEST_VERBOSE'};
+ my @has = get_rights( $m, $everyone_gid, 'RT::System-1' );
+ if (@has) {
+ $m->form_name('group_rights_modify');
+ $m->tick( "revoke_right-$everyone_gid-RT::System-1", $_ ) foreach @has;
+ $m->submit;
+
+ is_deeply( [ get_rights( $m, $everyone_gid, 'RT::System-1' ) ],
+ [], 'deleted all rights' );
+ }
+ else {
+ ok( 1, 'the group has no global rights' );
+ }
+
+ diag "grant SuperUser right to everyone" if $ENV{'TEST_VERBOSE'};
+ {
+ $m->form_name('group_rights_modify');
+ $m->select( "grant_right-$everyone_gid-RT::System-1", ['SuperUser'] );
+ $m->submit;
+
+ $m->content_contains( 'Right granted', 'got message' );
+ RT::Model::Principal::invalidate_acl_cache();
+ ok(
+ $everyone->principal->has_right(
+ right => 'SuperUser',
+ object => RT->system
+ ),
+ 'group has right'
+ );
+ is_deeply( [ get_rights( $m, $everyone_gid, 'RT::System-1' ) ],
+ ['SuperUser'], 'granted SuperUser right' );
+ }
+
+ diag "revoke the right" if $ENV{'TEST_VERBOSE'};
+ {
+ $m->form_name('group_rights_modify');
+ $m->tick( "revoke_right-$everyone_gid-RT::System-1", 'SuperUser' );
+ $m->submit;
+
+ $m->content_contains( 'Right revoked', 'got message' );
+ RT::Model::Principal::invalidate_acl_cache();
+ ok(
+ !$everyone->principal->has_right(
+ right => 'SuperUser',
+ object => RT->system
+ ),
+ 'group has no right'
+ );
+ is_deeply( [ get_rights( $m, $everyone_gid, 'RT::System-1' ) ],
+ [], 'revoked SuperUser right' );
+ }
+ diag "return rights the group had in the beginning" if $ENV{'TEST_VERBOSE'};
+ if (@has) {
+ $m->form_name('group_rights_modify');
+ $m->select( "grant_right-$everyone_gid-RT::System-1", \@has );
+ $m->submit;
-diag "return rights the group had in the beginning" if $ENV{'TEST_VERBOSE'};
-if ( @has ) {
- $m->form_name('group_rights_modify');
- $m->select("grant_right-$everyone_gid-RT::System-1", \@has);
- $m->submit;
-
- $m->content_contains('right Granted', 'got message');
- is_deeply(
- [ get_rights( $m, $everyone_gid, 'RT::System-1' ) ],
- [ @has ],
- 'returned back all rights'
- );
-} else {
- ok(1, 'the group had no global rights, so nothing to return');
+ $m->content_contains( 'right Granted', 'got message' );
+ is_deeply( [ get_rights( $m, $everyone_gid, 'RT::System-1' ) ],
+ [@has], 'returned back all rights' );
+ }
+ else {
+ ok( 1, 'the group had no global rights, so nothing to return' );
+ }
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list