File: encoding.t

package info (click to toggle)
request-tracker5 5.0.3%2Bdfsg-3~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 77,648 kB
  • sloc: javascript: 187,930; perl: 79,061; sh: 1,302; makefile: 471; python: 37; php: 15
file content (43 lines) | stat: -rw-r--r-- 1,507 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use strict;
use warnings;

use RT;
use RT::Test::ExternalStorage tests => undef;
RT->Config->Set( ExternalStorageCutoffSize => 1 );

my $queue = RT::Test->load_or_create_queue(Name => 'General');

my $non_english_text = Encode::decode("UTF-8",'Příliš žluťoučký kůň pěl ďábelské ódy');

my $message = MIME::Entity->build(
    From     => 'root@localhost',
    Subject  => 'test',
    Charset  => 'UTF-8',
    Encoding => 'quoted-printable',
    Type     => 'text/plain',
    Data     => Encode::encode('UTF-8', $non_english_text),
);

my $ticket = RT::Ticket->new( RT->SystemUser );
my ($id) = $ticket->Create(
    Queue => $queue,
    Subject => 'test',
    MIMEObj => $message,
);

ok $id, 'created a ticket';

my @attachments = @{ $ticket->Transactions->First->Attachments->ItemsArrayRef };
is scalar @attachments, 1, "Found one attachment";
is $attachments[0]->ContentType, "text/plain", "Found the text part";
is $attachments[0]->Content, $non_english_text, "Can get the text part content";

ok( RT::Test->run_singleton_command('sbin/rt-externalize-attachments'), "rt-externalize-attachments ran successfully" );

@attachments = @{ $ticket->Transactions->First->Attachments->ItemsArrayRef };
is scalar @attachments, 1, "Found one attachment";
is $attachments[0]->ContentType, "text/plain", "Found the text part";
is $attachments[0]->Content, $non_english_text, "Can still get the text part content";
is $attachments[0]->ContentEncoding, "external", "Content is external";

done_testing();