X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fapi%2Fattachment.t;h=52e3c3f1622ae33cb0f7eff56c29590468ebfac2;hb=ed1f84b4e8f626245995ecda5afcf83092c153b2;hp=07c46bad0fa74e88bf1288b426bb459a77979214;hpb=b4b0c7e72d7eaee2fbfc7022022c9698323203dd;p=freeside.git diff --git a/rt/t/api/attachment.t b/rt/t/api/attachment.t index 07c46bad0..52e3c3f16 100644 --- a/rt/t/api/attachment.t +++ b/rt/t/api/attachment.t @@ -2,7 +2,7 @@ use strict; use warnings; use RT; -use RT::Test tests => 4; +use RT::Test tests => 7; { @@ -42,4 +42,25 @@ is ($#headers, 2, "testing a bunch of singline multiple headers" ); } -1; + +{ + my $iso_8859_1_ticket_email = + RT::Test::get_relocatable_file( 'new-ticket-from-iso-8859-1', + ( File::Spec->updir(), 'data', 'emails' ) ); + my $content = RT::Test->file_content($iso_8859_1_ticket_email); + + my $parser = RT::EmailParser->new; + $parser->ParseMIMEEntityFromScalar($content); + my $attachment = RT::Attachment->new( $RT::SystemUser ); + my ( $id, $msg ) = + $attachment->Create( TransactionId => 1, Attachment => $parser->Entity ); + ok( $id, $msg ); + my $mime = $attachment->ContentAsMIME; + like( $mime->head->get('Content-Type'), + qr/charset="iso-8859-1"/, 'content type of ContentAsMIME is original' ); + is( + Encode::decode( 'iso-8859-1', $mime->stringify_body ), + Encode::decode( 'UTF-8', "HÃ¥vard\n" ), + 'body of ContentAsMIME is original' + ); +}