summaryrefslogtreecommitdiff
path: root/rt/t/api/attachment_filename.t
blob: bcbfe0057d475558feb35ab8716746ca8c276c66 (plain)
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
use RT::Test tests => 5;
use MIME::Entity;
my $ticket = RT::Ticket->new(RT->SystemUser);
my $mime   = MIME::Entity->build(
    From => 'test@example.com',
    Type => 'text/html',
    Data => ["test attachment's filename\n"],
);

$mime->attach(
    Path     => 'share/html/NoAuth/images/bpslogo.png',
    Type     => 'image/png',
);

$mime->attach(
    Path     => 'share/html/NoAuth/images/bpslogo.png',
    Type     => 'image/png',
    Filename => 'bpslogo.png',
);

$mime->attach(
    Path     => 'share/html/NoAuth/images/bpslogo.png',
    Filename => 'images/bpslogo.png',
    Type     => 'image/png',
);

my $id = $ticket->Create( MIMEObj => $mime, Queue => 'General' );
ok( $id, "created ticket $id" );

my $atts = RT::Attachments->new( RT->SystemUser );
$atts->Limit( FIELD => 'ContentType', VALUE => 'image/png' );
is( $atts->Count, 3, 'got 3 png files' );

# no matter if mime's filename include path or not,
# we should throw away the path all the time.
while ( my $att = $atts->Next ) {
    is( $att->Filename, 'bpslogo.png', "attachment's filename" );
}