6 use RT::Test tests => 28;
8 my ( $baseurl, $m ) = RT::Test->started_ok;
9 ok $m->login, 'logged in as root';
11 $RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
17 diag 'test without attachments' if $ENV{TEST_VERBOSE};
20 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
25 fields => { Subject => '标题', Content => '测试' },
27 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
28 $m->follow_link_ok( { text => 'with headers' },
29 '-> /Ticket/Attachment/WithHeaders/...' );
30 $m->content_contains( '标题', 'has subject 标题' );
31 $m->content_contains( '测试', 'has content 测试' );
33 my ( $id ) = $m->uri =~ /(\d+)$/;
34 ok( $id, 'found attachment id' );
35 my $attachment = RT::Attachment->new( $RT::SystemUser );
36 ok($attachment->Load($id), "load att $id");
37 # let make original encoding to gbk
38 ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
39 'set original encoding to gbk' );
41 $m->content_contains( '标题', 'has subject 标题' );
42 $m->content_contains( '测试', 'has content 测试' );
45 diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
50 File::Spec->catfile( File::Spec->tmpdir, 'rt_attachemnt_abcde.txt' );
51 open( my $fh, '>', $file ) or die $!;
56 $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
61 fields => { Subject => '标题', Content => '测试', Attach => $file },
63 $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
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_regex => qr/by Enoch Root/ },
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 附件' );