[Rt-commit] rt branch, html-templates, updated. rt-3.9.6-36-g120cf32

Thomas Sibley trs at bestpractical.com
Wed Nov 24 14:37:24 EST 2010


The branch, html-templates has been updated
       via  120cf321a4368c2ac2daa3a10d771b96330fa53a (commit)
       via  20ba42150ccb33566b2d27f797a0f6904c5baeaf (commit)
      from  5dfee3f8fadc214dd062dad78cad0f6b1882d294 (commit)

Summary of changes:
 lib/RT/Test.pm      |   29 +++++++++++++++++++++++++++++
 t/api/txn_content.t |    8 ++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit 20ba42150ccb33566b2d27f797a0f6904c5baeaf
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Nov 24 14:17:13 2010 -0500

    Test plain text templates by default
    
    Tests for HTML templates will come later

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 0695da2..0b3e05e 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -176,6 +176,14 @@ 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";
+    }
+
     Test::More->export_to_level($level);
 
     # blow away their diag so we can redefine it without warning
@@ -775,6 +783,24 @@ sub add_rights {
     return 1;
 }
 
+=head2 switch_templates_to TYPE
+
+This runs etc/upgrade/switch-templates-to in order to change the templates from
+HTML to text or vice versa.  TYPE is the type to switch to, either C<html> or
+C<text>.
+
+=cut
+
+sub switch_templates_to {
+    my $self = shift;
+    my $type = shift;
+
+    return $self->run_and_capture(
+        command => "$RT::EtcPath/upgrade/switch-templates-to",
+        args    => $type,
+    );
+}
+
 sub run_mailgate {
     my $self = shift;
 
@@ -813,10 +839,13 @@ sub run_and_capture {
 
     $cmd .= ' --debug' if delete $args{'debug'};
 
+    my $args = delete $args{'args'};
+
     while( my ($k,$v) = each %args ) {
         next unless $v;
         $cmd .= " --$k '$v'";
     }
+    $cmd .= " $args" if defined $args;
     $cmd .= ' 2>&1';
 
     DBIx::SearchBuilder::Record::Cachable->FlushCache;

commit 120cf321a4368c2ac2daa3a10d771b96330fa53a
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Nov 24 14:29:42 2010 -0500

    Fix this test for the new HTML -> text converter

diff --git a/t/api/txn_content.t b/t/api/txn_content.t
index 392b6a7..d44862d 100644
--- a/t/api/txn_content.t
+++ b/t/api/txn_content.t
@@ -1,7 +1,7 @@
 use warnings;
 use strict;
 
-use RT::Test tests => 3;
+use RT::Test tests => 4;
 use MIME::Entity;
 my $ticket = RT::Ticket->new(RT->SystemUser);
 my $mime   = MIME::Entity->build(
@@ -16,4 +16,8 @@ my $txns = $ticket->Transactions;
 $txns->Limit( FIELD => 'Type', VALUE => 'Create' );
 my $txn = $txns->First;
 ok( $txn, 'got Create txn' );
-is( $txn->Content, "this is body\n", "txn's content" );
+
+# ->Content converts from text/html to plain text if we don't explicitly ask
+# for html. Our html -> text converter seems to add an extra trailing newline
+is( $txn->Content, "this is body\n\n", "txn's html content converted to plain text" );
+is( $txn->Content(Type => 'text/html'), "this is body\n", "txn's html content" );

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


More information about the Rt-commit mailing list