[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-64-g0a79e9c
? sunnavy
sunnavy at bestpractical.com
Fri May 28 04:03:13 EDT 2010
The branch, 3.8-trunk has been updated
via 0a79e9c674d77fb31ccf423ad793817a408d079b (commit)
via 57f4e6d5f2295f9d33304899df0d095d91abe689 (commit)
from 9b3f0b3c3df79888a3d17beada3e94965c945eeb (commit)
Summary of changes:
lib/RT/Transaction_Overlay.pm | 27 ++++++++------
t/web/ticket_txn_content.t | 79 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 12 deletions(-)
create mode 100644 t/web/ticket_txn_content.t
- Log -----------------------------------------------------------------
commit 57f4e6d5f2295f9d33304899df0d095d91abe689
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri May 28 15:31:41 2010 +0800
add ticket_txn_content.t to test 6a9eed79
diff --git a/t/web/ticket_txn_content.t b/t/web/ticket_txn_content.t
new file mode 100644
index 0000000..1c1056a
--- /dev/null
+++ b/t/web/ticket_txn_content.t
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -w
+use strict;
+
+use RT::Test tests => 37;
+use File::Temp 'tempfile';
+use File::Spec;
+my ( $plain_fh, $plain_file ) =
+ tempfile( 'rttestXXXXXX', SUFFIX => '.txt', UNLINK => 1, TMPDIR => 1 );
+print $plain_fh "this is plain content";
+close $plain_fh;
+my $plain_name = (File::Spec->splitpath($plain_file))[-1];
+
+my ( $html_fh, $html_file ) =
+ tempfile( 'rttestXXXXXX', SUFFIX => '.html', UNLINK => 1, TMPDIR => 1 );
+print $html_fh "this is html content";
+close $html_fh;
+my $html_name = (File::Spec->splitpath($html_file))[-1];
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+my $queue = RT::Queue->new($RT::Nobody);
+my $qid = $queue->Load('General');
+ok( $qid, "Loaded General queue" );
+
+RT::Test->set_mail_catcher;
+RT::Test->clean_caught_mails;
+
+for my $type ( 'text/plain', 'text/html' ) {
+ $m->form_name('CreateTicketInQueue');
+ $m->field( 'Queue', $qid );
+ $m->submit;
+ is( $m->status, 200, "request successful" );
+ $m->content_like( qr/Create a new ticket/, 'ticket create page' );
+
+ $m->form_name('TicketCreate');
+ $m->field( 'Subject', 'with plain attachment' );
+ $m->field( 'Attach', $plain_file );
+ $m->field( 'Content', 'this is main content' );
+ $m->field( 'ContentType', $type ) unless $type eq 'text/plain';
+ $m->submit;
+ is( $m->status, 200, "request successful" );
+ $m->content_like( qr/with plain attachment/,
+ 'we have subject on the page' );
+ $m->content_like( qr/this is main content/, 'main content' );
+ $m->content_like( qr/Download $plain_name/, 'download plain file link' );
+
+ my ( $mail ) = RT::Test->fetch_caught_mails;
+ like( $mail, qr/this is main content/, 'email contains main content' );
+ # check the email link in page too
+ $m->follow_link_ok( { text => 'Show' }, 'show the email outgoing' );
+ $m->content_like( qr/this is main content/, 'email contains main content');
+ $m->back;
+
+ $m->follow_link_ok( { text => 'Reply' }, "reply to the ticket" );
+ $m->form_name('TicketUpdate');
+ $m->field( 'Attach', $plain_file );
+ $m->click('AddMoreAttach');
+ is( $m->status, 200, "request successful" );
+
+ $m->form_name('TicketUpdate');
+ $m->field( 'Attach', $html_file );
+ # add UpdateCc so we can get email record
+ $m->field( 'UpdateCc', 'rt-test at example.com' );
+ $m->field( 'UpdateContent', 'this is main reply content' );
+ $m->field( 'UpdateContentType', $type ) unless $type eq 'text/plain';
+ $m->click('SubmitTicket');
+ is( $m->status, 200, "request successful" );
+
+ $m->content_like( qr/this is main reply content/, 'main reply content' );
+ $m->content_like( qr/Download $html_name/, 'download html file link' );
+
+ ( $mail ) = RT::Test->fetch_caught_mails;
+ like( $mail, qr/this is main reply content/, 'email contains main reply content' );
+ # check the email link in page too
+ $m->follow_link_ok( { text => 'Show', n => 2 }, 'show the email outgoing' );
+ $m->content_like( qr/this is main reply content/, 'email contains main reply content');
+ $m->back;
+}
commit 0a79e9c674d77fb31ccf423ad793817a408d079b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri May 28 15:32:55 2010 +0800
reapply 6a9eed792, with tiny tweaks
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index 96ccf51..4671236 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -292,21 +292,23 @@ If $args{'Type'} is set to C<text/html>, this will return an HTML
part of the message, if available. Otherwise it looks for a text/plain
part. If $args{'Type'} is missing, it defaults to the value of
C<$RT::Transaction::PreferredContentType>, if that's missing too,
-defaults to 'text/plain'.
+defaults to textual.
=cut
sub Content {
my $self = shift;
my %args = (
- Type => $PreferredContentType || 'text/plain',
+ Type => '',
Quote => 0,
Wrap => 70,
@_
);
my $content;
- if ( my $content_obj = $self->ContentObj( Type => $args{Type} ) ) {
+ if ( my $content_obj =
+ $self->ContentObj( $args{Type} ? ( Type => $args{Type} ) : () ) )
+ {
$content = $content_obj->Content ||'';
if ( lc $content_obj->ContentType eq 'text/html' ) {
@@ -397,8 +399,7 @@ Returns the RT::Attachment object which contains the content for this Transactio
sub ContentObj {
my $self = shift;
- my %args = ( Type => $PreferredContentType || 'text/plain',
- @_ );
+ my %args = ( Type => $PreferredContentType, @_ );
# If we don't have any content, return undef now.
# Get the set of toplevel attachments to this transaction.
@@ -413,13 +414,15 @@ sub ContentObj {
# MIME type ('text/plain' by default).
elsif ( $Attachment->ContentType =~ '^multipart/' ) {
- my $plain_parts = $Attachment->Children;
- $plain_parts->ContentType( VALUE => $args{Type} );
- $plain_parts->LimitNotEmpty;
-
- # If we actully found a part, return its content
- if ( my $first = $plain_parts->First ) {
- return $first;
+ if ( $args{Type} ) {
+ my $plain_parts = $Attachment->Children;
+ $plain_parts->ContentType( VALUE => $args{Type} );
+ $plain_parts->LimitNotEmpty;
+
+ # If we actully found a part, return its content
+ if ( my $first = $plain_parts->First ) {
+ return $first;
+ }
}
# If that fails, return the first textual part which has some content.
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list