6 use RT::Test tests => 32;
8 my ( $baseurl, $m ) = RT::Test->started_ok;
9 ok $m->login, 'logged in as root';
15 diag 'test without attachments' if $ENV{TEST_VERBOSE};
18 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
20 $m->form_name('TicketModify');
23 fields => { Subject => '标题', Content => '测试' },
25 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
26 $m->follow_link_ok( { text => 'with headers' },
27 '-> /Ticket/Attachment/WithHeaders/...' );
28 $m->content_contains( '标题', 'has subject 标题' );
29 $m->content_contains( '测试', 'has content 测试' );
31 my ( $id ) = $m->uri =~ /(\d+)$/;
32 ok( $id, 'found attachment id' );
33 my $attachment = RT::Attachment->new( $RT::SystemUser );
34 ok($attachment->Load($id), "load att $id");
35 # let make original encoding to gbk
36 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
37 'set original encoding to gbk' );
39 $m->content_contains( '标题', 'has subject 标题' );
40 $m->content_contains( '测试', 'has content 测试' );
43 diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
48 File::Spec->catfile( RT::Test->temp_directory, encode_utf8 '附件.txt' );
49 open( my $fh, '>', $file ) or die $!;
54 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
56 $m->form_name('TicketModify');
59 fields => { Subject => '标题', Content => '测试', Attach => $file },
61 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
62 $m->content_contains( '附件.txt', 'attached filename' );
63 $m->content_lacks( encode_utf8 '附件.txt', 'no double encoded attached filename' );
64 $m->follow_link_ok( { text => 'with headers' },
65 '-> /Ticket/Attachment/WithHeaders/...' );
67 # subject is in the parent attachment, so there is no 标题
68 $m->content_lacks( '标题', 'does not have content 标题' );
69 $m->content_contains( '测试', 'has content 测试' );
71 my ( $id ) = $m->uri =~ /(\d+)$/;
72 ok( $id, 'found attachment id' );
73 my $attachment = RT::Attachment->new( $RT::SystemUser );
74 ok($attachment->Load($id), "load att $id");
75 # let make original encoding to gbk
76 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
77 'set original encoding to gbk' );
79 $m->content_lacks( '标题', 'does not have content 标题' );
80 $m->content_contains( '测试', 'has content 测试' );
85 $m->follow_link_ok( { text => 'Download 附件.txt' },
86 '-> /Ticket/Attachment/...' );
87 $m->content_contains( '附件', 'has content 附件' );
89 ( $id ) = $m->uri =~ /(\d+)\D+$/;
90 ok( $id, 'found attachment id' );
91 $attachment = RT::Attachment->new( $RT::SystemUser );
92 ok($attachment->Load($id), "load att $id");
94 # let make original encoding to gbk
95 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
96 'set original encoding to gbk' );
98 $m->content_contains( '附件', 'has content 附件' );