rest-non-ascii-subject.t 1.35 KB
Newer Older
1
2
3
# Test ticket creation with REST using non ascii subject
use strict;
use warnings;
sunnavy's avatar
sunnavy committed
4
use RT::Test tests => 9;
5

Ruslan Zakirov's avatar
Ruslan Zakirov committed
6
7
8
9
use Encode;
# \x{XX} where XX is less than 255 is not treated as unicode code point
my $subject = Encode::decode('latin1', "Sujet accentu\x{e9}");
my $text = Encode::decode('latin1', "Contenu accentu\x{e9}");
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

my ($baseurl, $m) = RT::Test->started_ok;

my $queue = RT::Test->load_or_create_queue(Name => 'General');
ok($queue->Id, "loaded the General queue");

my $content = "id: ticket/new
Queue: General
Requestor: root
Subject: $subject
Cc:
AdminCc:
Owner:
Status: new
Priority:
InitialPriority:
FinalPriority:
TimeEstimated:
Starts: 2009-03-10 16:14:55
Due: 2009-03-10 16:14:55
Text: $text";

$m->post("$baseurl/REST/1.0/ticket/new", [
    user    => 'root',
    pass    => 'password',
35
    content => Encode::encode( "UTF-8", $content),
36
37
38
39
40
], Content_Type => 'form-data' );

my ($id) = $m->content =~ /Ticket (\d+) created/;
ok($id, "got ticket #$id");

41
my $ticket = RT::Ticket->new(RT->SystemUser);
42
43
44
$ticket->Load($id);
is($ticket->Id, $id, "loaded the REST-created ticket");
is($ticket->Subject, $subject, "ticket subject successfully set");
Ruslan Zakirov's avatar
Ruslan Zakirov committed
45
46
47

my $attach = $ticket->Transactions->First->Attachments->First;
is($attach->Subject, $subject, "attachement subject successfully set");
48
is($attach->GetHeader('Subject'), $subject, "attachement header subject successfully set");