[Rt-commit] rt branch, html-templates, updated. rt-3.9.6-49-g7386067

Thomas Sibley trs at bestpractical.com
Tue Dec 7 15:38:58 EST 2010


The branch, html-templates has been updated
       via  73860678d54659c45837125fb7d59ec41b7c6363 (commit)
      from  044b0337c271ae0c8e2d3f8c3f70ab45ba417175 (commit)

Summary of changes:
 lib/RT/Test.pm                                     |   10 ++---
 ...ts-outgoing.t => charsets-outgoing-plaintext.t} |    2 +-
 t/mail/charsets-outgoing.t                         |    6 ++--
 ...pted.t => gnupg-outgoing-encrypted-plaintext.t} |    5 ++-
 ...ng-plain.t => gnupg-outgoing-plain-plaintext.t} |    5 ++-
 ...-signed.t => gnupg-outgoing-signed-plaintext.t} |    5 ++-
 ...=> gnupg-outgoing-signed_encrypted-plaintext.t} |    5 ++-
 t/mail/html-outgoing.t                             |    4 +--
 t/mail/{sendmail.t => sendmail-plaintext.t}        |    2 +-
 t/mail/sendmail.t                                  |   37 +++++++++++++-------
 t/web/html_template.t                              |    2 +-
 11 files changed, 47 insertions(+), 36 deletions(-)
 copy t/mail/{charsets-outgoing.t => charsets-outgoing-plaintext.t} (99%)
 copy t/mail/{gnupg-outgoing-encrypted.t => gnupg-outgoing-encrypted-plaintext.t} (90%)
 copy t/mail/{gnupg-outgoing-plain.t => gnupg-outgoing-plain-plaintext.t} (89%)
 copy t/mail/{gnupg-outgoing-signed.t => gnupg-outgoing-signed-plaintext.t} (90%)
 copy t/mail/{gnupg-outgoing-signed_encrypted.t => gnupg-outgoing-signed_encrypted-plaintext.t} (90%)
 copy t/mail/{sendmail.t => sendmail-plaintext.t} (99%)

- Log -----------------------------------------------------------------
commit 73860678d54659c45837125fb7d59ec41b7c6363
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue Dec 7 10:53:50 2010 -0500

    Default to testing the HTML templates instead
    
    Provide a text_templates import flag to use text templates if necessary.
    
    Tests which failed originally with HTML templates enabled were copied to
    a t/mail/*-plaintext.t filenames and flipped back to testing plaintext.
    The original files were fixed to expect the New World Order of HTML.
    This way both the new HTML templates and the old plaintext templates are
    tested.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 2c05449..7b1b67d 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -176,12 +176,10 @@ sub import {
         $level++;
     }
 
-    # By default we test plain text templates for legacy's sake
-    my ($exit, $output) = $class->switch_templates_to('text');
-
-    if (my $num = $exit >> 8) {
-        warn "**** Trouble switching templates to plain text (exited $num):\n";
-        warn $output, "\n";
+    # By default we test HTML templates, but text templates are
+    # available on request
+    if ( $args{'text_templates'} ) {
+        $class->switch_templates_ok('text');
     }
 
     Test::More->export_to_level($level);
diff --git a/t/mail/charsets-outgoing.t b/t/mail/charsets-outgoing-plaintext.t
similarity index 99%
copy from t/mail/charsets-outgoing.t
copy to t/mail/charsets-outgoing-plaintext.t
index 59af27e..94cd4dd 100644
--- a/t/mail/charsets-outgoing.t
+++ b/t/mail/charsets-outgoing-plaintext.t
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 use Encode;
 
-use RT::Test tests => 78;
+use RT::Test tests => 79, text_templates => 1;
 
 my %string = (
     ru => {
diff --git a/t/mail/charsets-outgoing.t b/t/mail/charsets-outgoing.t
index 59af27e..dc79c53 100644
--- a/t/mail/charsets-outgoing.t
+++ b/t/mail/charsets-outgoing.t
@@ -36,7 +36,7 @@ diag "make sure queue has no subject tag";
 diag "set intial simple autoreply template";
 {
     my $template = RT::Template->new( RT->SystemUser );
-    $template->Load('Autoreply');
+    $template->Load('Autoreply in HTML');
     ok $template->id, "loaded autoreply tempalte";
 
     my ($status, $msg) = $template->SetContent(
@@ -148,7 +148,7 @@ foreach my $prefix_set ( 'ru', 'latin1' ) {
 diag "add non-ascii subject prefix in the autoreply template";
 {
     my $template = RT::Template->new( RT->SystemUser );
-    $template->Load('Autoreply');
+    $template->Load('Autoreply in HTML');
     ok $template->id, "loaded autoreply tempalte";
 
     my ($status, $msg) = $template->SetContent(
@@ -252,7 +252,7 @@ diag "don't change subject via template";
 # we should test situation when subject is not changed from template
 {
     my $template = RT::Template->new( RT->SystemUser );
-    $template->Load('Autoreply');
+    $template->Load('Autoreply in HTML');
     ok $template->id, "loaded autoreply tempalte";
 
     my ($status, $msg) = $template->SetContent(
diff --git a/t/mail/gnupg-outgoing-encrypted-plaintext.t b/t/mail/gnupg-outgoing-encrypted-plaintext.t
new file mode 100644
index 0000000..1959e32
--- /dev/null
+++ b/t/mail/gnupg-outgoing-encrypted-plaintext.t
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use RT::Test::GnuPG
+  tests          => 102,
+  text_templates => 1,
+  gnupg_options  => {
+    passphrase    => 'rt-test',
+    'trust-model' => 'always',
+  };
+
+RT::Test->import_gnupg_key('rt-recipient at example.com');
+RT::Test->import_gnupg_key( 'rt-test at example.com', 'public' );
+
+my $queue = RT::Test->load_or_create_queue(
+    Name              => 'Regression',
+    CorrespondAddress => 'rt-recipient at example.com',
+    CommentAddress    => 'rt-recipient at example.com',
+    Encrypt           => 1,
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+create_and_test_outgoing_emails( $queue, $m );
+
diff --git a/t/mail/gnupg-outgoing-plain-plaintext.t b/t/mail/gnupg-outgoing-plain-plaintext.t
new file mode 100644
index 0000000..aef0870
--- /dev/null
+++ b/t/mail/gnupg-outgoing-plain-plaintext.t
@@ -0,0 +1,26 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use RT::Test::GnuPG
+  tests          => 102,
+  text_templates => 1,
+  gnupg_options  => {
+    passphrase    => 'rt-test',
+    'trust-model' => 'always',
+  };
+
+RT::Test->import_gnupg_key('rt-recipient at example.com');
+RT::Test->import_gnupg_key( 'rt-test at example.com', 'public' );
+
+my $queue = RT::Test->load_or_create_queue(
+    Name              => 'Regression',
+    CorrespondAddress => 'rt-recipient at example.com',
+    CommentAddress    => 'rt-recipient at example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+create_and_test_outgoing_emails( $queue, $m );
diff --git a/t/mail/gnupg-outgoing-signed-plaintext.t b/t/mail/gnupg-outgoing-signed-plaintext.t
new file mode 100644
index 0000000..5afedba
--- /dev/null
+++ b/t/mail/gnupg-outgoing-signed-plaintext.t
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use RT::Test::GnuPG
+  tests          => 102,
+  text_templates => 1,
+  gnupg_options  => {
+    passphrase    => 'rt-test',
+    'trust-model' => 'always',
+  };
+
+RT::Test->import_gnupg_key('rt-recipient at example.com');
+RT::Test->import_gnupg_key( 'rt-test at example.com', 'public' );
+
+my $queue = RT::Test->load_or_create_queue(
+    Name              => 'Regression',
+    CorrespondAddress => 'rt-recipient at example.com',
+    CommentAddress    => 'rt-recipient at example.com',
+    Sign              => 1,
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+create_and_test_outgoing_emails( $queue, $m );
+
diff --git a/t/mail/gnupg-outgoing-signed_encrypted-plaintext.t b/t/mail/gnupg-outgoing-signed_encrypted-plaintext.t
new file mode 100644
index 0000000..40b5ca0
--- /dev/null
+++ b/t/mail/gnupg-outgoing-signed_encrypted-plaintext.t
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use RT::Test::GnuPG
+  tests          => 102,
+  text_templates => 1,
+  gnupg_options  => {
+    passphrase    => 'rt-test',
+    'trust-model' => 'always',
+  };
+
+RT::Test->import_gnupg_key('rt-recipient at example.com');
+RT::Test->import_gnupg_key( 'rt-test at example.com', 'public' );
+
+my $queue = RT::Test->load_or_create_queue(
+    Name              => 'Regression',
+    CorrespondAddress => 'rt-recipient at example.com',
+    CommentAddress    => 'rt-recipient at example.com',
+    Sign              => 1,
+    Encrypt           => 1,
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+create_and_test_outgoing_emails( $queue, $m );
+
diff --git a/t/mail/html-outgoing.t b/t/mail/html-outgoing.t
index 8560fe5..d20dd63 100644
--- a/t/mail/html-outgoing.t
+++ b/t/mail/html-outgoing.t
@@ -4,11 +4,9 @@ use RT::Test tests => undef;
 BEGIN {
     plan skip_all => 'Email::Abstract and Test::Email required.'
         unless eval { require Email::Abstract; require Test::Email; 1 };
-    plan tests => 19;
+    plan tests => 18;
 }
 
-RT::Test->switch_templates_ok('html');
-
 use RT::Test::Email;
 
 my $root = RT::User->new(RT->SystemUser);
diff --git a/t/mail/sendmail.t b/t/mail/sendmail-plaintext.t
similarity index 99%
copy from t/mail/sendmail.t
copy to t/mail/sendmail-plaintext.t
index 05a59bd..af3c626 100644
--- a/t/mail/sendmail.t
+++ b/t/mail/sendmail-plaintext.t
@@ -3,7 +3,7 @@
 use strict;
 use File::Spec ();
 
-use RT::Test tests => 139;
+use RT::Test tests => 140, text_templates => 1;
 use Test::Warn;
 
 use RT::EmailParser;
diff --git a/t/mail/sendmail.t b/t/mail/sendmail.t
index 05a59bd..8921013 100644
--- a/t/mail/sendmail.t
+++ b/t/mail/sendmail.t
@@ -3,7 +3,7 @@
 use strict;
 use File::Spec ();
 
-use RT::Test tests => 139;
+use RT::Test tests => 172;
 use Test::Warn;
 
 use RT::EmailParser;
@@ -205,9 +205,13 @@ sub utf8_redef_sendmessage {
                   "hey, look. it's a mime entity" );
         main::is( ref( $MIME->head ) , 'MIME::Head',
                   "its mime header is a mime header. yay" );
-        main::like( $MIME->head->get('Content-Type') , qr/utf-8/,
-                  "Its content type is utf-8" );
-        my $message_as_string = $MIME->bodyhandle->as_string();
+        main::like( $MIME->head->get('Content-Type') , qr/multipart\/alternative/,
+                  "Its content type is multipart/alternative" );
+        main::like( $MIME->parts(0)->head->get('Content-Type') , qr/text\/plain.+?utf-8/,
+                  "first part's content type is text/plain utf-8" );
+        main::like( $MIME->parts(1)->head->get('Content-Type') , qr/text\/html.+?utf-8/,
+                  "second part's content type is text/html utf-8" );
+        my $message_as_string = $MIME->parts(0)->bodyhandle->as_string();
         use Encode;
         $message_as_string = Encode::decode_utf8($message_as_string);
         main::like(
@@ -231,9 +235,14 @@ sub iso8859_redef_sendmessage {
                   "hey, look. it's a mime entity" );
         main::is( ref( $MIME->head ) , 'MIME::Head',
                   "its mime header is a mime header. yay" );
-        main::like( $MIME->head->get('Content-Type') , qr/iso-8859-1/,
-                  "Its content type is iso-8859-1 - " . $MIME->head->get("Content-Type") );
-        my $message_as_string = $MIME->bodyhandle->as_string();
+
+        main::like( $MIME->head->get('Content-Type') , qr/multipart\/alternative/,
+                  "Its content type is multipart/alternative" );
+        main::like( $MIME->parts(0)->head->get('Content-Type') , qr/text\/plain.+?iso-8859-1/,
+                  "Its content type is iso-8859-1 - " . $MIME->parts(0)->head->get("Content-Type") );
+        main::like( $MIME->parts(1)->head->get('Content-Type') , qr/text\/html.+?iso-8859-1/,
+                  "Its content type is iso-8859-1 - " . $MIME->parts(1)->head->get("Content-Type") );
+        my $message_as_string = $MIME->parts(0)->bodyhandle->as_string();
         use Encode;
         $message_as_string = Encode::decode("iso-8859-1",$message_as_string);
         main::like(
@@ -298,9 +307,9 @@ sub text_html_redef_sendmessage {
         my $self = shift;
         my $MIME = shift;
         return (1) unless ($self->ScripObj->ScripActionObj->Name eq "Notify AdminCcs" );
-        is ($MIME->parts, 0, "generated correspondence mime entity
-                does not have parts");
-        is ($MIME->head->mime_type , "text/plain", "The mime type is a plain");
+        is ($MIME->parts, 2, "generated correspondence mime entity has parts");
+        is ($MIME->parts(0)->head->mime_type , "text/plain", "The first part mime type is a plain");
+        is ($MIME->parts(1)->head->mime_type , "text/html", "The second part mime type is a plain");
     };
 }
 
@@ -320,8 +329,7 @@ warnings_like {
  RT::Interface::Email::Gateway(\%args);
 }
 [
-    qr/Encoding error: "\\x\{041f\}" does not map to iso-8859-1 .*/,
-    qr/Encoding error: "\\x\{041f\}" does not map to iso-8859-1 .*/
+    (qr/Encoding error: "\\x\{041f\}" does not map to iso-8859-1 .*/) x 5
     ],
 "The badly formed Russian spam we have isn't actually well-formed UTF8, which makes Encode (correctly) warn";
 
@@ -366,7 +374,10 @@ sub text_plain_russian_redef_sendmessage {
         my $self = shift; 
         my $MIME = shift; 
         return (1) unless ($self->ScripObj->ScripActionObj->Name eq "Notify AdminCcs" );
-        is ($MIME->head->mime_type , "text/plain", "The only part is text/plain ");
+        is ($MIME->head->mime_type , "multipart/alternative", "The top part is multipart/alternative");
+        is ($MIME->parts, 2, "generated correspondence mime entity has parts");
+        is ($MIME->parts(0)->head->mime_type , "text/plain", "The first part mime type is a plain");
+        is ($MIME->parts(1)->head->mime_type , "text/html", "The second part mime type is a plain");
             my $subject  = $MIME->head->get("subject");
         chomp($subject);
         #is( $subject ,      /^=\?KOI8-R\?B\?W2V4YW1wbGUuY39tICM3XSDUxdPUINTF09Q=\?=/ , "The $subject is encoded correctly");
diff --git a/t/web/html_template.t b/t/web/html_template.t
index 9b6e0d9..2953e88 100644
--- a/t/web/html_template.t
+++ b/t/web/html_template.t
@@ -17,7 +17,7 @@ diag('make Autoreply template a html one and add utf8 chars')
 
 {
     $m->follow_link_ok( { id => 'tools-config-global-templates' },     '-> Templates' );
-    $m->follow_link_ok( { text => 'Autoreply' },     '-> Autoreply' );
+    $m->follow_link_ok( { text => 'Autoreply in HTML' },       '-> Autoreply in HTML' );
 
     $m->submit_form(
         form_name => 'ModifyTemplate',

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


More information about the Rt-commit mailing list