[Rt-commit] rt branch, admin_ui, updated. 2affed777ae0581dc95f487ac508157cc726d4b7
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Tue Dec 29 21:46:49 EST 2009
The branch, admin_ui has been updated
via 2affed777ae0581dc95f487ac508157cc726d4b7 (commit)
from 58880741a0230ddf32bab2e7e4f8a4bb3c63b5ad (commit)
Summary of changes:
t/web/cf_access.t | 67 ++++++++++--------------------------
t/web/cf_onqueue.t | 88 ++++++++++++++++++-----------------------------
t/web/cf_select_one.t | 57 ++++++++-----------------------
t/web/crypt-gnupg.t | 32 ++++++-----------
t/web/gnupg-outgoing.t | 13 ++-----
5 files changed, 82 insertions(+), 175 deletions(-)
- Log -----------------------------------------------------------------
commit 2affed777ae0581dc95f487ac508157cc726d4b7
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Dec 30 10:46:32 2009 +0800
refactor tests that use /Admin/ but just use it as prepare work: not use /admin at all
diff --git a/t/web/cf_access.t b/t/web/cf_access.t
index a56dc4d..69ffcfa 100644
--- a/t/web/cf_access.t
+++ b/t/web/cf_access.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test strict => 1, tests => 26, l10n => 1;
+use RT::Test strict => 1, tests => 21, l10n => 1;
$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
@@ -10,58 +10,25 @@ my ($baseurl, $m) = RT::Test->started_ok;
use constant ImageFile => RT->static_path .'/images/bplogo.gif';
use constant ImageFileContent => RT::Test->file_content(ImageFile);
-ok $m->login, 'logged in';
-
-my $cf_moniker = 'edit-ticket-cfs';
-
diag "Create a CF" if $ENV{'TEST_VERBOSE'};
-{
- $m->follow_link( text => 'Configuration' );
- $m->title_is(q/RT Administration/, 'admin screen');
- $m->follow_link( text => 'Custom Fields', url_regex =>
- qr!Admin/CustomFields! );
- $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
- $m->follow_link( text => 'Create' );
- $m->submit_form(
- form_name => "modify_custom_field",
- fields => {
- type_composite => 'Image-0',
- lookup_type => 'RT::Model::Queue-RT::Model::Ticket',
- name => 'img',
- description => 'img',
- },
- );
-}
+my $cf = RT::Model::CustomField->new( current_user => RT->system_user );
+my ( $status, $msg ) = $cf->create(
+ name => 'img',
+ description => 'img',
+ type => 'Image',
+ lookup_type => 'RT::Model::Queue-RT::Model::Ticket',
+);
+ok( $status, $msg );
+my $cfid = $cf->id;
diag "apply the CF to General queue" if $ENV{'TEST_VERBOSE'};
-my ( $cf, $cfid, $tid );
-{
- $m->title_is(q/Created CustomField img/, 'admin-cf Created');
- $m->follow_link( text => 'Queues', url_regex => qr!/Admin/Queues! );
- $m->title_is(q/Admin queues/, 'admin-queues screen');
- $m->follow_link( text => 'General', url_regex => qr!/Admin/Queues! );
- $m->title_is(q/Editing Configuration for queue General/, 'admin-queue: general');
- $m->follow_link( text => 'Ticket Custom Fields' );
-
- $m->title_is(q/Edit Custom Fields for General/, 'admin-queue: general cfid');
- $m->form_name('edit_custom_fields');
-
- # Sort by numeric IDs in names
- my @names = map { $_->[1] }
- sort { $a->[0] <=> $b->[0] }
- map { /object-1-CF-(\d+)/ ? [ $1 => $_ ] : () }
- grep defined, map $_->name, $m->current_form->inputs;
- $cf = pop(@names);
- $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
- $cfid = $1;
- $m->field( $cf => 1 ); # Associate the new CF with this queue
- $m->field( $_ => undef ) for @names; # ...and not any other. ;-)
- $m->submit;
-
- $m->content_like( qr/created/, 'TCF added to the queue' );
-
-}
+my $queue = RT::Model::Queue->new( current_user => RT->system_user );
+( $status, $msg ) = $queue->load( 'General' );
+ok( $status, $msg );
+( $status, $msg ) = $cf->add_to_object( $queue );
+ok( $status, $msg );
+my ( $tid );
my $tester = RT::Test->load_or_create_user( name => 'tester', password => '123456' );
RT::Test->set_rights(
{ principal => $tester->principal,
@@ -70,6 +37,8 @@ RT::Test->set_rights(
);
ok $m->login( $tester->name, 123456), 'logged in';
+my $cf_moniker = 'edit-ticket-cfs';
+
diag "check that we have no the CF on the create"
." ticket page when user has no SeeCustomField right"
if $ENV{'TEST_VERBOSE'};
diff --git a/t/web/cf_onqueue.t b/t/web/cf_onqueue.t
index 986fdce..3c6827c 100644
--- a/t/web/cf_onqueue.t
+++ b/t/web/cf_onqueue.t
@@ -1,67 +1,47 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test strict => 1, tests => 14, l10n => 1;
+use RT::Test strict => 1, tests => 4, l10n => 1;
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
diag "Create a queue CF" if $ENV{'TEST_VERBOSE'};
-{
- $m->follow_link( text => 'Configuration' );
- $m->title_is(q/RT Administration/, 'admin screen');
- $m->follow_link( text => 'Custom Fields', url_regex =>
- qr!Admin/CustomFields! );
- $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
- $m->follow_link( text => 'Create' );
- $m->submit_form(
- form_name => 'modify_custom_field',
- fields => {
- type_composite => 'Freeform-1',
- lookup_type => 'RT::Model::Queue',
- name => 'QueueCFTest',
- description => 'QueueCFTest',
- },
- );
- $m->content_like( qr/Object created/, 'CF QueueCFTest created' );
-}
+my $cf = RT::Model::CustomField->new( current_user => RT->system_user );
+my ( $status, $msg ) = $cf->create(
+ name => 'QueueCFTest',
+ description => 'QueueCFTest',
+ type => 'Freeform',
+ lookup_type => 'RT::Model::Queue',
+ max_values => 1,
+);
-diag "Apply the new CF globally" if $ENV{'TEST_VERBOSE'};
-{
- $m->follow_link( text => 'Global' );
- $m->title_is(q!Admin/Global configuration!, 'global configuration screen');
- $m->follow_link( url_regex => qr!Admin/Global/CustomFields/index! );
- $m->title_is(q/Global custom field configuration/, 'global custom field configuration screen');
- $m->follow_link( url => 'Queues.html' );
- $m->title_is(q/Edit Custom Fields for all queues/, 'global custom field for all queues configuration screen');
- $m->content_like( qr/QueueCFTest/, 'CF QueueCFTest displayed on page' );
- $m->submit_form(
- form_name => 'edit_custom_fields',
- fields => {
- 'object--CF-1' => '1',
- },
- );
- $m->content_like( qr/Object created/, 'CF QueueCFTest enabled globally' );
-}
-
-diag "Edit the CF value for default queue" if $ENV{'TEST_VERBOSE'};
-{
- $m->follow_link( url => '/Admin/Queues/' );
- $m->title_is(q/Admin queues/, 'queues configuration screen');
- $m->follow_link( text => "1" );
- $m->title_is(q/Editing Configuration for queue General/, 'default queue configuration screen');
- $m->content_like( qr/QueueCFTest/, 'CF QueueCFTest displayed on default queue' );
- $m->submit_form(
- form_name => 'queue_modify',
- # The following doesn't want to works :(
- #with_fields => { 'object-RT::Model::Queue-1-CustomField-1-value' },
- fields => {
- 'object-RT::Model::Queue-1-CustomField-1-value' => 'QueueCFTest content',
- },
- );
- $m->content_like( qr/QueueCFTest QueueCFTest content added/, 'Content filed in CF QueueCFTest for default queue' );
+ok( $status, $msg );
-}
+diag "Apply the new CF globally" if $ENV{'TEST_VERBOSE'};
+my $queue = RT::Model::Queue->new( current_user => RT->system_user );
+( $status, $msg ) = $cf->add_to_object( $queue );
+ok( $status, $msg );
+
+# TODO we need add cf support for queue in /admin/
+#diag "Edit the CF value for default queue" if $ENV{'TEST_VERBOSE'};
+#{
+# $m->follow_link( url => '/admin/queues/' );
+# $m->title_is(q/Admin queues/, 'queues configuration screen');
+# $m->follow_link( text => "1" );
+# $m->title_is(q/Editing Configuration for queue General/, 'default queue configuration screen');
+# $m->content_like( qr/QueueCFTest/, 'CF QueueCFTest displayed on default queue' );
+# $m->submit_form(
+# form_name => 'queue_modify',
+ # The following doesn't want to works :(
+ #with_fields => { 'object-RT::Model::Queue-1-CustomField-1-value' },
+# fields => {
+# 'object-RT::Model::Queue-1-CustomField-1-value' => 'QueueCFTest content',
+# },
+# );
+# $m->content_like( qr/QueueCFTest QueueCFTest content added/, 'Content filed in CF QueueCFTest for default queue' );
+#
+#}
__END__
diff --git a/t/web/cf_select_one.t b/t/web/cf_select_one.t
index c76d5c2..965e0a1 100644
--- a/t/web/cf_select_one.t
+++ b/t/web/cf_select_one.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use RT::Test strict => 1, tests => 41, l10n => 1;
+use RT::Test strict => 1, tests => 34, l10n => 1;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -12,39 +12,24 @@ ok $m->login, 'logged in as root';
my $cf_name = 'test select one value';
my $cf_moniker = 'edit-ticket-cfs';
-my $cfid;
diag "Create a CF" if $ENV{'TEST_VERBOSE'};
-{
- $m->follow_link( text => 'Configuration' );
- $m->title_is(q/RT Administration/, 'admin screen');
- $m->follow_link( text => 'Custom Fields', url_regex =>
- qr!Admin/CustomFields! );
- $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
- $m->follow_link( text => 'Create' );
- $m->submit_form(
- form_name => "modify_custom_field",
- fields => {
- name => $cf_name,
- type_composite => 'Select-1',
- lookup_type => 'RT::Model::Queue-RT::Model::Ticket',
- },
- );
- $m->content_like( qr/created/, 'Created CF sucessfully' );
- $cfid = $m->form_name('modify_custom_field')->value('id');
- ok $cfid, "found id of the CF in the form, it's #$cfid";
-}
+
+my $cf = RT::Model::CustomField->new( current_user => RT->system_user );
+my ( $status, $msg ) = $cf->create(
+ name => $cf_name,
+ type => 'Select',
+ lookup_type => 'RT::Model::Queue-RT::Model::Ticket',
+ max_values => 1,
+);
+ok( $status, $msg );
+my $cfid = $cf->id;
+
diag "add 'qwe', 'ASD' and '0' as values to the CF" if $ENV{'TEST_VERBOSE'};
{
foreach my $value(qw(qwe ASD 0)) {
- $m->submit_form(
- form_name => "modify_custom_field",
- fields => {
- "CustomField-". $cfid ."-value-new-name" => $value,
- },
- button => 'update',
- );
- $m->content_like( qr/created/, 'added a value to the CF' ); # or diag $m->content;
+ my ( $status, $msg ) = $cf->add_value( name => $value );
+ ok( $status, $msg );
}
}
@@ -52,20 +37,8 @@ my $queue = RT::Test->load_or_create_queue( name => 'General' );
ok $queue && $queue->id, 'loaded or Created queue';
diag "apply the CF to General queue" if $ENV{'TEST_VERBOSE'};
-{
- $m->follow_link( text => 'Queues', url_regex => qr!/Admin/Queues! );
- $m->title_is(q/Admin queues/, 'admin-queues screen');
- $m->follow_link( text => 'General', url_regex => qr!/Admin/Queues! );
- $m->title_is(q/Editing Configuration for queue General/, 'admin-queue: general');
- $m->follow_link( text => 'Ticket Custom Fields' );
- $m->title_is(q/Edit Custom Fields for General/, 'admin-queue: general cfid');
-
- $m->form_name('edit_custom_fields');
- $m->field( "object-". $queue->id ."-CF-$cfid" => 1 );
- $m->submit;
+$cf->add_to_object( $queue );
- $m->content_like( qr/created/, 'TCF added to the queue' );
-}
my $tid;
diag "create a ticket using API with 'asd'(not 'ASD') as value of the CF"
diff --git a/t/web/crypt-gnupg.t b/t/web/crypt-gnupg.t
index 6d1db3a..a95a5b5 100644
--- a/t/web/crypt-gnupg.t
+++ b/t/web/crypt-gnupg.t
@@ -9,7 +9,7 @@ plan skip_all => 'GnuPG required.'
plan skip_all => 'gpg executable is required.'
unless RT::Test->find_executable('gpg');
-plan tests => 93;
+plan tests => 61;
use RT::ScripAction::SendEmail;
@@ -80,12 +80,8 @@ my ($baseurl, $m) = RT::Test->started_ok;
diag($baseurl) if $ENV{TEST_VERBOSE};
ok $m->login, 'logged in';
-$m->get_ok("/Admin/Queues/Modify.html?id=$qid");
-$m->form_with_fields('sign', 'encrypt');
-$m->field(encrypt => 1);
-$m->submit;
-
-RT::Test->clean_caught_mails;
+my ( $status, $msg ) = $queue->set_encrypt(1);
+ok( $status, $msg );
$m->goto_create_ticket( $queue );
$m->fill_in_action_ok(create_ticket => (
@@ -152,13 +148,10 @@ MAIL
like($attachments[0]->content, qr/$rtname/, "RT's mail includes this instance's name");
}
-$m->get("$baseurl/Admin/Queues/Modify.html?id=$qid");
-$m->form_with_fields('sign', 'encrypt');
-$m->field(encrypt => undef);
-$m->field(sign => 1);
-$m->submit;
-
-RT::Test->clean_caught_mails;
+( $status, $msg ) = $queue->set_encrypt(undef);
+ok( $status, $msg );
+( $status, $msg ) = $queue->set_sign(1);
+ok( $status, $msg );
$m->goto_create_ticket( $queue );
$m->fill_in_action_ok(create_ticket => (
@@ -228,13 +221,10 @@ MAIL
like($attachments[0]->content, qr/$rtname/, "RT's mail includes this instance's name");
}
-$m->get("$baseurl/Admin/Queues/Modify.html?id=$qid");
-$m->form_with_fields('sign', 'encrypt');
-$m->field(encrypt => 1);
-$m->field(sign => 1);
-$m->submit;
-
-RT::Test->clean_caught_mails;
+( $status, $msg ) = $queue->set_encrypt(1);
+ok( $status, $msg );
+( $status, $msg ) = $queue->set_sign(1);
+ok( $status, $msg );
$user->set_email('recipient at example.com');
$m->goto_create_ticket( $queue );
diff --git a/t/web/gnupg-outgoing.t b/t/web/gnupg-outgoing.t
index e4f1750..dec3d3a 100644
--- a/t/web/gnupg-outgoing.t
+++ b/t/web/gnupg-outgoing.t
@@ -10,7 +10,7 @@ plan skip_all => 'GnuPG required.'
plan skip_all => 'gpg executable is required.'
unless RT::Test->find_executable('gpg');
-plan tests => 492;
+plan tests => 381;
use RT::ScripAction::SendEmail;
use File::Temp qw(tempdir);
@@ -358,15 +358,10 @@ sub cleanup_headers {
sub set_queue_crypt_options {
my %args = @_;
- $m->get_ok("/Admin/Queues/Modify.html?id=". $queue->id);
- $m->form_with_fields('sign', 'encrypt');
foreach my $opt ('sign', 'encrypt') {
- if ( $args{$opt} ) {
- $m->tick($opt => 1);
- } else {
- $m->untick($opt => 1);
- }
+ my $method = "set_$opt";
+ my ( $status, $msg ) = $queue->$method( $args{$opt} );
+ ok( $status, $msg );
}
- $m->submit;
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list