RT 4.2.11, ticket#13852
[freeside.git] / rt / t / api / txn_content.t
1 use warnings;
2 use strict;
3
4 use RT::Test tests => 4;
5 use MIME::Entity;
6 my $ticket = RT::Ticket->new(RT->SystemUser);
7 my $mime   = MIME::Entity->build(
8     From => 'test@example.com',
9     Type => 'text/html',
10     Data => ["this is body\n"],
11 );
12 $mime->attach( Data => ['this is attachment'] );
13 my $id = $ticket->Create( MIMEObj => $mime, Queue => 'General' );
14 ok( $id, "created ticket $id" );
15 my $txns = $ticket->Transactions;
16 $txns->Limit( FIELD => 'Type', VALUE => 'Create' );
17 my $txn = $txns->First;
18 ok( $txn, 'got Create txn' );
19
20 # ->Content converts from text/html to plain text if we don't explicitly ask
21 # for html. Our html -> text converter seems to add an extra trailing newline
22 like( $txn->Content, qr/^\s*this is body\s*$/, "txn's html content converted to plain text" );
23 is( $txn->Content(Type => 'text/html'), "this is body\n", "txn's html content" );