projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RT 4.0.22
[freeside.git]
/
rt
/
t
/
web
/
attachment_encoding.t
diff --git
a/rt/t/web/attachment_encoding.t
b/rt/t/web/attachment_encoding.t
index
9ba5677
..
f49720e
100644
(file)
--- a/
rt/t/web/attachment_encoding.t
+++ b/
rt/t/web/attachment_encoding.t
@@
-1,34
+1,32
@@
-#!/usr/bin/perl
use strict;
use warnings;
use strict;
use warnings;
-use RT::Test tests => 28;
-use Encode;
+use RT::Test tests => 32;
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
-$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
-
-use utf8;
-
use File::Spec;
use File::Spec;
+my $subject = Encode::decode("UTF-8",'标题');
+my $content = Encode::decode("UTF-8",'测试');
+my $filename = Encode::decode("UTF-8",'附件.txt');
+
diag 'test without attachments' if $ENV{TEST_VERBOSE};
{
$m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
diag 'test without attachments' if $ENV{TEST_VERBOSE};
{
$m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
- $m->form_n
umber(3
);
+ $m->form_n
ame('TicketModify'
);
$m->submit_form(
form_number => 3,
$m->submit_form(
form_number => 3,
- fields => { Subject =>
'标题', Content => '测试'
},
+ fields => { Subject =>
$subject, Content => $content
},
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
$m->follow_link_ok( { text => 'with headers' },
'-> /Ticket/Attachment/WithHeaders/...' );
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
$m->follow_link_ok( { text => 'with headers' },
'-> /Ticket/Attachment/WithHeaders/...' );
- $m->content_contains(
'标题', 'has subject 标题'
);
- $m->content_contains(
'测试', 'has content 测试'
);
+ $m->content_contains(
$subject, "has subject $subject"
);
+ $m->content_contains(
$content, "has content $content"
);
my ( $id ) = $m->uri =~ /(\d+)$/;
ok( $id, 'found attachment id' );
my ( $id ) = $m->uri =~ /(\d+)$/;
ok( $id, 'found attachment id' );
@@
-38,8
+36,8
@@
diag 'test without attachments' if $ENV{TEST_VERBOSE};
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
- $m->content_contains(
'标题', 'has subject 标题'
);
- $m->content_contains(
'测试', 'has content 测试'
);
+ $m->content_contains(
$subject, "has subject $subject"
);
+ $m->content_contains(
$content, "has content $content"
);
}
diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
}
diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
@@
-47,26
+45,28
@@
diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
{
my $file =
{
my $file =
- File::Spec->catfile(
File::Spec->tmpdir, 'rt_attachemnt_abcde.txt'
);
+ File::Spec->catfile(
RT::Test->temp_directory, Encode::encode("UTF-8",$filename)
);
open( my $fh, '>', $file ) or die $!;
binmode $fh, ':utf8';
open( my $fh, '>', $file ) or die $!;
binmode $fh, ':utf8';
- print $fh
'附件'
;
+ print $fh
$filename
;
close $fh;
$m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
close $fh;
$m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
- $m->form_n
umber(3
);
+ $m->form_n
ame('TicketModify'
);
$m->submit_form(
form_number => 3,
$m->submit_form(
form_number => 3,
- fields => { Subject =>
'标题', Content => '测试'
, Attach => $file },
+ fields => { Subject =>
$subject, Content => $content
, Attach => $file },
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+ $m->content_contains( $filename, 'attached filename' );
+ $m->content_lacks( Encode::encode("UTF-8",$filename), 'no double encoded attached filename' );
$m->follow_link_ok( { text => 'with headers' },
'-> /Ticket/Attachment/WithHeaders/...' );
# subject is in the parent attachment, so there is no 标题
$m->follow_link_ok( { text => 'with headers' },
'-> /Ticket/Attachment/WithHeaders/...' );
# subject is in the parent attachment, so there is no 标题
- $m->content_lacks(
'标题', 'does not have content 标题'
);
- $m->content_contains(
'测试', 'has content 测试'
);
+ $m->content_lacks(
$subject, "does not have content $subject"
);
+ $m->content_contains(
$content, "has content $content"
);
my ( $id ) = $m->uri =~ /(\d+)$/;
ok( $id, 'found attachment id' );
my ( $id ) = $m->uri =~ /(\d+)$/;
ok( $id, 'found attachment id' );
@@
-76,15
+76,15
@@
diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
- $m->content_lacks(
'标题', 'does not have content 标题'
);
- $m->content_contains(
'测试', 'has content 测试'
);
+ $m->content_lacks(
$subject, "does not have content $subject"
);
+ $m->content_contains(
$content, "has content $content"
);
$m->back;
$m->back;
$m->back;
$m->back;
- $m->follow_link_ok( { text
_regex => qr/by Enoch Root/
},
+ $m->follow_link_ok( { text
=> "Download $filename"
},
'-> /Ticket/Attachment/...' );
'-> /Ticket/Attachment/...' );
- $m->content_contains(
'附件', 'has content 附件'
);
+ $m->content_contains(
$filename, "has file content $filename"
);
( $id ) = $m->uri =~ /(\d+)\D+$/;
ok( $id, 'found attachment id' );
( $id ) = $m->uri =~ /(\d+)\D+$/;
ok( $id, 'found attachment id' );
@@
-95,9
+95,8
@@
diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
- $m->content_contains(
'附件', 'has content 附件'
);
+ $m->content_contains(
$filename, "has content $filename"
);
unlink $file;
}
unlink $file;
}
-