[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-185-g2bf9cb4

Chia-liang Kao clkao at bestpractical.com
Wed Oct 20 05:10:55 EDT 2010


The branch, 3.9-trunk has been updated
       via  2bf9cb4b1172c194d5cdbb3b20d4654be1f35106 (commit)
      from  943466c58b16e86bae1651da483840c76096a826 (commit)

Summary of changes:
 lib/RT/Test/GnuPG.pm                |   57 +++++++++++++++++++++++-----------
 t/web/gnupg-select-keys-on-create.t |   32 -------------------
 t/web/gnupg-select-keys-on-update.t |   33 --------------------
 3 files changed, 38 insertions(+), 84 deletions(-)

- Log -----------------------------------------------------------------
commit 2bf9cb4b1172c194d5cdbb3b20d4654be1f35106
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Oct 20 18:10:35 2010 +0900

    A more generic check_text_emails from gnupg-select-keys* tests

diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
index 878aaa3..8446f8c 100644
--- a/lib/RT/Test/GnuPG.pm
+++ b/lib/RT/Test/GnuPG.pm
@@ -3,7 +3,7 @@ use strict;
 use Test::More;
 use base qw(RT::Test);
 
-our @EXPORT = qw(create_a_ticket update_ticket check_text_emails cleanup_headers set_queue_crypt_options);
+our @EXPORT = qw(create_a_ticket update_ticket cleanup_headers set_queue_crypt_options check_text_emails);
 
 sub import {
     my $class = shift;
@@ -48,7 +48,8 @@ sub create_a_ticket {
 
 
     my @mail = RT::Test->fetch_caught_mails;
-    check_text_emails($mail, \%args, @mail );
+    check_text_emails(\%args, @mail );
+    categorize_emails($mail, \%args, @mail );
 }
 
 sub update_ticket {
@@ -77,29 +78,15 @@ sub update_ticket {
 
 
     my @mail = RT::Test->fetch_caught_mails;
-    check_text_emails($mail, \%args, @mail );
+    check_text_emails(\%args, @mail );
+    categorize_emails($mail, \%args, @mail );
 }
 
-sub check_text_emails {
+sub categorize_emails {
     my %mail = %{ shift @_ };
     my %args = %{ shift @_ };
     my @mail = @_;
 
-    ok scalar @mail, "got some mail";
-    for my $mail (@mail) {
-        if ( $args{'Encrypt'} ) {
-            unlike $mail, qr/Some content/, "outgoing email was encrypted";
-        } else {
-            like $mail, qr/Some content/, "outgoing email was not encrypted";
-        } 
-        if ( $args{'Sign'} && $args{'Encrypt'} ) {
-            like $mail, qr/BEGIN PGP MESSAGE/, 'outgoing email was signed';
-        } elsif ( $args{'Sign'} ) {
-            like $mail, qr/SIGNATURE/, 'outgoing email was signed';
-        } else {
-            unlike $mail, qr/SIGNATURE/, 'outgoing email was not signed';
-        }
-    }
     if ( $args{'Sign'} && $args{'Encrypt'} ) {
         push @{ $mail{'signed_encrypted'} }, @mail;
     } elsif ( $args{'Sign'} ) {
@@ -111,6 +98,38 @@ sub check_text_emails {
     }
 }
 
+sub check_text_emails {
+    my %args = %{ shift @_ };
+    my @mail = @_;
+
+    ok scalar @mail, "got some mail";
+    for my $mail (@mail) {
+        for my $type ('email', 'attachment') {
+            next if $type eq 'attachment' && !$args{'Attachment'};
+
+            my $content = $type eq 'email'
+                        ? "Some content"
+                        : "Attachment content";
+
+            if ( $args{'Encrypt'} ) {
+                unlike $mail, qr/$content/, "outgoing $type was encrypted";
+            } else {
+                like $mail, qr/$content/, "outgoing $type was not encrypted";
+            } 
+
+            next unless $type eq 'email';
+
+            if ( $args{'Sign'} && $args{'Encrypt'} ) {
+                like $mail, qr/BEGIN PGP MESSAGE/, 'outgoing email was signed';
+            } elsif ( $args{'Sign'} ) {
+                like $mail, qr/SIGNATURE/, 'outgoing email was signed';
+            } else {
+                unlike $mail, qr/SIGNATURE/, 'outgoing email was not signed';
+            }
+        }
+    }
+}
+
 sub cleanup_headers {
     my $mail = shift;
     # strip id from subject to create new ticket
diff --git a/t/web/gnupg-select-keys-on-create.t b/t/web/gnupg-select-keys-on-create.t
index f3e1dd5..8254844 100644
--- a/t/web/gnupg-select-keys-on-create.t
+++ b/t/web/gnupg-select-keys-on-create.t
@@ -299,35 +299,3 @@ diag "check encrypting of attachments";
     $m->no_warnings_ok;
 }
 
-sub check_text_emails {
-    my %args = %{ shift @_ };
-    my @mail = @_;
-
-    ok scalar @mail, "got some mail";
-    for my $mail (@mail) {
-        for my $type ('email', 'attachment') {
-            next if $type eq 'attachment' && !$args{'Attachment'};
-
-            my $content = $type eq 'email'
-                        ? "Some content"
-                        : "Attachment content";
-
-            if ( $args{'Encrypt'} ) {
-                unlike $mail, qr/$content/, "outgoing $type was encrypted";
-            } else {
-                like $mail, qr/$content/, "outgoing $type was not encrypted";
-            } 
-
-            next unless $type eq 'email';
-
-            if ( $args{'Sign'} && $args{'Encrypt'} ) {
-                like $mail, qr/BEGIN PGP MESSAGE/, 'outgoing email was signed';
-            } elsif ( $args{'Sign'} ) {
-                like $mail, qr/SIGNATURE/, 'outgoing email was signed';
-            } else {
-                unlike $mail, qr/SIGNATURE/, 'outgoing email was not signed';
-            }
-        }
-    }
-}
-
diff --git a/t/web/gnupg-select-keys-on-update.t b/t/web/gnupg-select-keys-on-update.t
index 62a6002..94009f1 100644
--- a/t/web/gnupg-select-keys-on-update.t
+++ b/t/web/gnupg-select-keys-on-update.t
@@ -319,36 +319,3 @@ diag "check encrypting of attachments";
 
     $m->no_warnings_ok;
 }
-
-sub check_text_emails {
-    my %args = %{ shift @_ };
-    my @mail = @_;
-
-    ok scalar @mail, "got some mail";
-    for my $mail (@mail) {
-        for my $type ('email', 'attachment') {
-            next if $type eq 'attachment' && !$args{'Attachment'};
-
-            my $content = $type eq 'email'
-                        ? "Some content"
-                        : "Attachment content";
-
-            if ( $args{'Encrypt'} ) {
-                unlike $mail, qr/$content/, "outgoing $type was encrypted";
-            } else {
-                like $mail, qr/$content/, "outgoing $type was not encrypted";
-            } 
-
-            next unless $type eq 'email';
-
-            if ( $args{'Sign'} && $args{'Encrypt'} ) {
-                like $mail, qr/BEGIN PGP MESSAGE/, 'outgoing email was signed';
-            } elsif ( $args{'Sign'} ) {
-                like $mail, qr/SIGNATURE/, 'outgoing email was signed';
-            } else {
-                unlike $mail, qr/SIGNATURE/, 'outgoing email was not signed';
-            }
-        }
-    }
-}
-

-----------------------------------------------------------------------


More information about the Rt-commit mailing list