RT 4.0.22
[freeside.git] / rt / t / web / ticket_txn_subject.t
1 use strict;
2 use warnings;
3
4 use RT::Test tests => undef;
5
6 my ($base, $m) = RT::Test->started_ok;
7 ok $m->login, 'logged in';
8
9 my @tickets;
10
11 diag "create a ticket via the API";
12 {
13     my $ticket = RT::Ticket->new( RT->SystemUser );
14     my ($id, $txn, $msg) = $ticket->Create(
15         Queue => 'General',
16         Subject => Encode::decode("UTF-8",'bad subject‽'),
17     );
18     ok $id, 'created a ticket #'. $id or diag "error: $msg";
19     is $ticket->Subject, Encode::decode("UTF-8",'bad subject‽'), 'correct subject';
20     push @tickets, $id;
21 }
22
23 diag "create a ticket via the web";
24 {
25     $m->submit_form_ok({
26         form_name => "CreateTicketInQueue",
27         fields    => { Queue => 1 },
28     }, 'create ticket in Queue');
29     $m->submit_form_ok({
30         with_fields => {
31             Subject => Encode::decode("UTF-8",'bad subject #2‽'),
32         },
33     }, 'create ticket');
34     $m->content_contains(Encode::decode("UTF-8",'bad subject #2‽'), 'correct subject');
35     push @tickets, 2;
36 }
37
38 diag "create a ticket via the web without a unicode subject";
39 {
40     $m->submit_form_ok({
41         with_fields => { Queue => 1 },
42     }, 'create ticket in Queue');
43     $m->submit_form_ok({
44         with_fields => {
45             Subject => 'a fine subject #3',
46         },
47     }, 'create ticket');
48     $m->content_contains('a fine subject #3', 'correct subject');
49     push @tickets, 3;
50 }
51
52 for my $tid (@tickets) {
53     diag "ticket #$tid";
54     diag "add a reply which adds to the subject, but without an attachment";
55     {
56         $m->goto_ticket($tid);
57         $m->follow_link_ok({ id => 'page-actions-reply' }, "Actions -> Reply");
58         $m->submit_form_ok({
59             with_fields => {
60                 UpdateSubject => Encode::decode("UTF-8",'bad subject‽ without attachment'),
61                 UpdateContent => 'testing unicode txn subjects',
62             },
63             button => 'SubmitTicket',
64         }, 'submit reply');
65         $m->content_contains(Encode::decode("UTF-8",'bad subject‽ without attachment'), "found txn subject");
66     }
67
68     diag "add a reply which adds to the subject with an attachment";
69     {
70         $m->goto_ticket($tid);
71         $m->follow_link_ok({ id => 'page-actions-reply' }, "Actions -> Reply");
72         $m->submit_form_ok({
73             with_fields => {
74                 UpdateSubject => Encode::decode("UTF-8",'bad subject‽ with attachment'),
75                 UpdateContent => 'testing unicode txn subjects',
76                 Attach => RT::Test::get_relocatable_file('bpslogo.png', '..', 'data'),
77             },
78             button => 'SubmitTicket',
79         }, 'submit reply');
80         $m->content_contains(Encode::decode("UTF-8",'bad subject‽ with attachment'), "found txn subject");
81     }
82 }
83
84 undef $m;
85 done_testing;