5 use RT::Test tests => 32;
7 my ( $baseurl, $m ) = RT::Test->started_ok;
8 ok $m->login, 'logged in as root';
14 diag 'test without attachments' if $ENV{TEST_VERBOSE};
17 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
19 $m->form_name('TicketModify');
22 fields => { Subject => '标题', Content => '测试' },
24 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
25 $m->follow_link_ok( { text => 'with headers' },
26 '-> /Ticket/Attachment/WithHeaders/...' );
27 $m->content_contains( '标题', 'has subject 标题' );
28 $m->content_contains( '测试', 'has content 测试' );
30 my ( $id ) = $m->uri =~ /(\d+)$/;
31 ok( $id, 'found attachment id' );
32 my $attachment = RT::Attachment->new( $RT::SystemUser );
33 ok($attachment->Load($id), "load att $id");
34 # let make original encoding to gbk
35 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
36 'set original encoding to gbk' );
38 $m->content_contains( '标题', 'has subject 标题' );
39 $m->content_contains( '测试', 'has content 测试' );
42 diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
47 File::Spec->catfile( RT::Test->temp_directory, encode_utf8 '附件.txt' );
48 open( my $fh, '>', $file ) or die $!;
53 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
55 $m->form_name('TicketModify');
58 fields => { Subject => '标题', Content => '测试', Attach => $file },
60 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
61 $m->content_contains( '附件.txt', 'attached filename' );
62 $m->content_lacks( encode_utf8 '附件.txt', 'no double encoded attached filename' );
63 $m->follow_link_ok( { text => 'with headers' },
64 '-> /Ticket/Attachment/WithHeaders/...' );
66 # subject is in the parent attachment, so there is no 标题
67 $m->content_lacks( '标题', 'does not have content 标题' );
68 $m->content_contains( '测试', 'has content 测试' );
70 my ( $id ) = $m->uri =~ /(\d+)$/;
71 ok( $id, 'found attachment id' );
72 my $attachment = RT::Attachment->new( $RT::SystemUser );
73 ok($attachment->Load($id), "load att $id");
74 # let make original encoding to gbk
75 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
76 'set original encoding to gbk' );
78 $m->content_lacks( '标题', 'does not have content 标题' );
79 $m->content_contains( '测试', 'has content 测试' );
84 $m->follow_link_ok( { text => 'Download 附件.txt' },
85 '-> /Ticket/Attachment/...' );
86 $m->content_contains( '附件', 'has content 附件' );
88 ( $id ) = $m->uri =~ /(\d+)\D+$/;
89 ok( $id, 'found attachment id' );
90 $attachment = RT::Attachment->new( $RT::SystemUser );
91 ok($attachment->Load($id), "load att $id");
93 # let make original encoding to gbk
94 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
95 'set original encoding to gbk' );
97 $m->content_contains( '附件', 'has content 附件' );