[Rt-commit] r9984 - in rtir/branches/2.3-EXPERIMENTAL: t/constituency

ruz at bestpractical.com ruz at bestpractical.com
Mon Dec 17 21:15:33 EST 2007


Author: ruz
Date: Mon Dec 17 21:15:32 2007
New Revision: 9984

Modified:
   rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
   rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t

Log:
* more tests of From: address in constituency autoreplies
* get rid of warning

Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm	Mon Dec 17 21:15:32 2007
@@ -505,9 +505,10 @@
         my $value;
         if ( $args{'MIMEObj'} ) {
             my $tmp = $args{'MIMEObj'}->head->get('X-RT-Mail-Extension');
-            chomp $tmp;
-            if ( $tmp && !grep lc $_->Name eq lc $tmp, @{ $cf->Values->ItemsArrayRef } ) {
-                $tmp = undef;
+            if ( $tmp ) {
+                chomp $tmp;
+                $tmp = undef unless
+                    grep lc $_->Name eq lc $tmp, @{ $cf->Values->ItemsArrayRef };
             }
             $value = $tmp;
             $RT::Logger->debug("Found Constituency '$tmp' in email") if $tmp;

Modified: rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/constituency/email_outgoing.t	Mon Dec 17 21:15:32 2007
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 20;
 
 use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
 require RT::Test; import RT::Test;
@@ -42,12 +42,20 @@
 );
 ok $queue_ir_edunet && $queue_ir_edunet->id, 'loaded or created queue';
 
+my $queue_ir_govnet = RT::Test->load_or_create_queue(
+    Name              => 'Incident Reports - GOVNET',
+    CorrespondAddress => 'gov-reports at example.com',
+    CommentAddress    => 'gov-reports-comment at example.com',
+);
+ok $queue_ir_govnet && $queue_ir_govnet->id, 'loaded or created queue';
+
 RT::Test->set_mail_catcher;
 
 my ($baseurl, $agent) = RT::Test->started_ok;
 my $rtir_user = rtir_user();
 $agent->login( rtir_test_user => 'rtir_test_pass' );
 
+diag "create an IR via base address";
 {
     unlink "t/mailbox";
 
@@ -62,6 +70,11 @@
     is $status >> 8, 0, "The mail gateway exited ok";
     ok $id, "created ticket $id";
 
+    my $ticket = RT::Ticket->new( $RT::SystemUser );
+    $ticket->Load( $id );
+    ok $ticket->id, 'loaded the ticket';
+    is $ticket->FirstCustomFieldValue('_RTIR_Constituency'), 'EDUNET', 'correct value';
+
     display_ticket($agent, $id);
     $agent->content_like( qr/\QEDUNET/, "value on the page" );
 
@@ -78,3 +91,39 @@
     ok $from_ok, 'all From addresses are correct';
 }
 
+diag "create an IR under GOVNET";
+{
+    unlink "t/mailbox";
+
+    my $text = <<EOF;
+From: @{[ $rtir_user->EmailAddress ]}
+To: gov-reports\@example.com
+Subject: This is a test of constituency functionality
+
+Foob!
+EOF
+    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports', extension => 'GOVNET');
+    is $status >> 8, 0, "The mail gateway exited ok";
+    ok $id, "created ticket $id";
+
+    my $ticket = RT::Ticket->new( $RT::SystemUser );
+    $ticket->Load( $id );
+    ok $ticket->id, 'loaded the ticket';
+    is $ticket->FirstCustomFieldValue('_RTIR_Constituency'), 'GOVNET', 'correct value';
+
+    display_ticket($agent, $id);
+    $agent->content_like( qr/GOVNET/, "value on the page" );
+
+    my @mail = RT::Test->fetch_caught_mails;
+    ok @mail, 'there are some outgoing emails';
+    
+    my $from_ok = 1;
+    foreach my $mail ( @mail ) {
+        next if $mail =~ /^From:\s*.*?gov-reports\@example\.com/mi;
+        diag $mail;
+        $from_ok = 0;
+        last;
+    }
+    ok $from_ok, 'all From addresses are correct';
+}
+


More information about the Rt-commit mailing list