[Rt-commit] r4911 - rtir/branches/1.9-EXPERIMENTAL/t
glasser at bestpractical.com
glasser at bestpractical.com
Thu Mar 30 15:15:36 EST 2006
Author: glasser
Date: Thu Mar 30 15:15:35 2006
New Revision: 4911
Added:
rtir/branches/1.9-EXPERIMENTAL/t/002-test-reject.t
Modified:
rtir/branches/1.9-EXPERIMENTAL/t/001-basic-RTIR.t
rtir/branches/1.9-EXPERIMENTAL/t/rtir-test.pl
Log:
refactor test suite and add one for new bug
Modified: rtir/branches/1.9-EXPERIMENTAL/t/001-basic-RTIR.t
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/t/001-basic-RTIR.t (original)
+++ rtir/branches/1.9-EXPERIMENTAL/t/001-basic-RTIR.t Thu Mar 30 15:15:35 2006
@@ -2,14 +2,26 @@
use strict;
use warnings;
-use Test::More tests => 19;
+use Test::More tests => 22;
require "t/rtir-test.pl";
my $agent = default_agent();
+my $SUBJECT = "foo " . rand;
+
# Create a report
-my $report = CreateReport(Subject => "foo", Content => "bar baz");
+my $report = create_ir($agent, {Subject => $SUBJECT, Content => "bla" });
+
+{
+ my $ir_obj = RT::Ticket->new($RT::SystemUser);
+ my $stifle_warnings = $RT::SystemUser;
+
+ $ir_obj->Load($report);
+ is($ir_obj->Id, $report, "report has right ID");
+ is($ir_obj->Subject, $SUBJECT, "subject is right");
+}
+
# Create a new Incident from that report
my $first_incident_id = NewIncidentFromChild(id => $report);
@@ -83,39 +95,6 @@
return;
}
-sub CreateReport {
- my %args = ( @_ );
-
- $agent->follow_link_ok({text => "Incident Reports", n => "1"}, "Followed 'Incident Reports' link");
-
- $agent->follow_link_ok({text => "New Report", n => "1"}, "Followed 'New Report' link");
-
- # set the form
- $agent->form_number(2);
-
- # set the subject
- $agent->field("Subject", $args{'Subject'});
-
- # set the content
- $agent->field("Content", $args{'Content'});
-
- # Create it!
- $agent->click("Create");
-
- is ($agent->status, 200, "Attempted to create the ticket");
-
- # Now see if we succeeded
- my $content = $agent->content();
- my $id = -1;
- if ($content =~ /.*Ticket (\d+) created.*/g) {
- $id = $1;
- }
-
- ok ($id > 0, "Ticket $id created successfully.");
-
- return $id;
-}
-
sub CreateIncident {
my %args = ( @_ );
Added: rtir/branches/1.9-EXPERIMENTAL/t/002-test-reject.t
==============================================================================
--- (empty file)
+++ rtir/branches/1.9-EXPERIMENTAL/t/002-test-reject.t Thu Mar 30 15:15:35 2006
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More tests => 53;
+
+require "t/rtir-test.pl";
+
+my $agent = default_agent();
+
+# Create some reports
+
+my $rtir_user = rtir_user();
+
+# We are testing that the reject and quick reject buttons both work
+# both for IRs that you own and IRs that are unowned. So we make four IRs to work with.
+
+my $nobody_slow = create_ir($agent, {Subject => "nobody slow", Owner => $RT::Nobody->Id });
+my $nobody_quick = create_ir($agent, {Subject => "nobody quick", Owner => $RT::Nobody->Id });
+my $me_slow = create_ir($agent, {Subject => "me slow", Owner => $rtir_user->Id });
+my $me_quick = create_ir($agent, {Subject => "me quick", Owner => $rtir_user->Id });
+
+
+for my $id ($nobody_slow, $nobody_quick) {
+ my $ir_obj = RT::Ticket->new($RT::SystemUser);
+ $ir_obj->Load($id);
+ is($ir_obj->Id, $id, "report has right ID");
+ is($ir_obj->Owner, $RT::Nobody->Id, "report owned by nobody");
+}
+
+for my $id ($me_slow, $me_quick) {
+ my $ir_obj = RT::Ticket->new($RT::SystemUser);
+ $ir_obj->Load($id);
+ is($ir_obj->Id, $id, "report has right ID");
+ is($ir_obj->Owner, $rtir_user->Id, "report owned by me");
+}
+
+for my $id ($nobody_quick, $me_quick) {
+ display_ir($agent, $id);
+ $agent->follow_link_ok({text => "Quick Reject"}, "Followed 'Quick Reject' link");
+
+ like($agent->content, qr/State changed from new to rejected/, "site says ticket got rejected");
+}
+
+for my $id ($nobody_slow, $me_slow) {
+ display_ir($agent, $id);
+
+ $agent->follow_link_ok({text => "Reject"}, "Followed 'Reject' link");
+
+ $agent->form_name("TicketUpdate");
+ $agent->field(UpdateContent => "why you are rejected");
+ $agent->click("SubmitTicket");
+
+ is ($agent->status, 200, "attempt to reject succeeded");
+
+ like($agent->content, qr/State changed from new to rejected/, "site says ticket got rejected");
+}
+
+# we need to flush the cache, or else later the status change will not be detected
+use DBIx::SearchBuilder::Record::Cachable;
+DBIx::SearchBuilder::Record::Cachable::FlushCache();
+
+
+for my $id ($nobody_slow, $nobody_quick, $me_quick, $me_slow) {
+ my $ir_obj = RT::Ticket->new($RT::SystemUser);
+ $ir_obj->Load($id);
+ is($ir_obj->Id, $id, "loaded ticket $id OK");
+ is($ir_obj->Status, 'rejected', "ticket $id is now rejected in DB");
+}
Modified: rtir/branches/1.9-EXPERIMENTAL/t/rtir-test.pl
==============================================================================
--- rtir/branches/1.9-EXPERIMENTAL/t/rtir-test.pl (original)
+++ rtir/branches/1.9-EXPERIMENTAL/t/rtir-test.pl Thu Mar 30 15:15:35 2006
@@ -73,8 +73,8 @@
}
sub create_user {
- my $user_obj = RT::User->new($RT::SystemUser);
- $user_obj->Load($RTIR_TEST_USER);
+ my $user_obj = rtir_user();
+
if ($user_obj->Id) {
$user_obj->SetPassword($RTIR_TEST_PASS);
} else {
@@ -95,4 +95,49 @@
ok($group_obj->HasMember($user_obj->PrincipalObj), "user is in the group");
}
+sub rtir_user {
+ my $u = RT::User->new($RT::SystemUser);
+ $u->Load($RTIR_TEST_USER);
+ return $u;
+}
+
+sub create_ir {
+ my $agent = shift;
+ my $fields = shift || {};
+ my $cfs = shift || {};
+
+ go_home($agent);
+
+ $agent->follow_link_ok({text => "Incident Reports", n => "1"}, "Followed 'Incident Reports' link");
+
+ $agent->follow_link_ok({text => "New Report", n => "1"}, "Followed 'New Report' link");
+
+ # set the form
+ $agent->form_number(2);
+
+ while (my ($f, $v) = each %$fields) {
+ $agent->field($f, $v);
+ }
+
+ while (my ($f, $v) = each %$cfs) {
+ set_custom_field($agent, $f, $v);
+ }
+
+ # Create it!
+ $agent->click("Create");
+
+ is ($agent->status, 200, "Attempted to create the ticket");
+
+ # Now see if we succeeded
+ my $content = $agent->content();
+ my $id = -1;
+ if ($content =~ /.*Ticket (\d+) created.*/g) {
+ $id = $1;
+ }
+
+ ok ($id > 0, "Ticket $id created successfully.");
+
+ return $id;
+}
+
1;
More information about the Rt-commit
mailing list