[Rt-commit] r3092 - in RT-Action-ExtractSubjectTag: . t

kevinr at bestpractical.com kevinr at bestpractical.com
Wed Jun 8 18:00:53 EDT 2005


Author: kevinr
Date: Wed Jun  8 18:00:53 2005
New Revision: 3092

Modified:
   RT-Action-ExtractSubjectTag/   (props changed)
   RT-Action-ExtractSubjectTag/t/01extract_tags.t
Log:
 r4067 at sad-girl-in-snow:  kevinr | 2005-06-08 17:59:27 -0400
 * Started adding tests for multiple tags in the subject


Modified: RT-Action-ExtractSubjectTag/t/01extract_tags.t
==============================================================================
--- RT-Action-ExtractSubjectTag/t/01extract_tags.t	(original)
+++ RT-Action-ExtractSubjectTag/t/01extract_tags.t	Wed Jun  8 18:00:53 2005
@@ -91,7 +91,7 @@
 my $match_count = 0;
 my $subject = $ticket->Subject;
 while ($subject =~ /\Q[foo.example #12]\E/g) { $match_count++; }
-ok($match_count eq 1, "Tag was not added a second time");
+ok($match_count eq 1, "The same tag was not added a second time");
 
 # create a new e-mail with another, different tag
 $email =~ s/\Q[foo.example #12]\E/[bar.example #24]/;
@@ -103,9 +103,9 @@
 # check to make sure the scrip will add that tag to the existing ticket
 ($id, $message, $transaction_obj) = $ticket->Correspond(MIMEObj=>$parser->Entity);
 ok($id, "conduct transaction? $message");
-ok($ticket->Subject =~ /\Q[bar.example #24]\E/, "Tag was added to ticket's subject");
+ok($ticket->Subject =~ /\Q[bar.example #24]\E/, "Second unique tag was added to ticket's subject");
 
-# create a new e-mail with the local RT's tag
+# create a new e-mail with the local RT instance's tag
 $email =~ s/\Q[foo.example #12]\E/[example.com #24]/;
 ($id, $message) = $parser->SmartParseMIMEEntityFromScalar( Message => $email, 
   Decode => 1 );
@@ -115,25 +115,48 @@
 # check to make sure the scrip will *NOT* add that tag to the existing ticket
 ($id, $message, $transaction_obj) = $ticket->Correspond(MIMEObj=>$parser->Entity);
 ok($id, "conduct transaction? $message");
-ok($ticket->Subject !~ /\Q[example.com #24]\E/, "Tag was not added to ticket's subject");
+ok($ticket->Subject !~ /\Q[example.com #24]\E/, "The local instance's tag was not added to ticket's subject");
 
-### test extraction of multiple tags from the same subject line ###
+### test extraction of multiple tags from the same e-mail subject line ###
 
 # create another new ticket
-
-=for comments
-
-my $ticket_mult = RT::Ticket->new($RT::SystemUser);
+my $user = RT::CurrentUser->new('root');
+ok ($user->id, "Found our user");
+my $ticket_mult = RT::Ticket->new($user);
 ($id, $transaction_obj, $message) 
    = $ticket->Create(  Requestor   => ['root at example.com'],
                        Queue       => 'general',
-                       Subject     => 'ExtractSubjectTag test',
+                       Subject     => 'Multiple ExtractSubjectTag test',
                     );
 ok ($id, "create new ticket? $message");
 
-=cut
+# parse a new e-mail with multiple tags
 
-# 
+my $email_mult = 
+('Subject: [example.net #12] Multiple ExtractSubjectTag test [example.org #42]
+From: root at example.com
+To: rt at example.com
+
+Foo Bar,
+
+Blah blah blah.
+
+Baz,
+Quux
+');
+($id, $message) = $parser->SmartParseMIMEEntityFromScalar( 
+  Message => $email_mult, Decode => 1 );
+ok($parser->Entity, "Parser returned a MIME entity");
+ok($parser->Entity->head, "Entity had a header:\n@{[$parser->Head->stringify]}");
+
+# check to make sure the scrip will add both tags to the ticket
+($id, $message, $transaction_obj) = $ticket_mult->Correspond(MIMEObj=>$parser->Entity);
+ok($id, "conduct transaction? $message");
+#ok(
+#  ($ticket_mult->Subject() =~ /\Q[foo.example #24]\E/) &&
+#  ($ticket_mult->Subject() =~ /\Q[bar.example #36]\E/),
+#  "Both tags were added to the ticket's subject"
+#);
 
 1;
 


More information about the Rt-commit mailing list