fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / ticket / clicky.t
1
2 use strict;
3 use warnings;
4 use Test::More;
5 use RT::Test tests => 20;
6
7 my $plain = MIME::Entity->build(
8     Subject => 'plain mime',
9     Type    => 'text/plain',
10     Data    => <<END,
11 If you have some problems with RT you could find help
12 on http://wiki.bestpractical.com or subscribe to
13 the rt-users\@lists.bestpractical.com.
14
15 to test anchor:
16 https://wiki.bestpractical.com/test#anchor
17 --
18 Best regards. BestPractical Team.
19 END
20 );
21
22 my $html = MIME::Entity->build(
23     Type    => 'text/html',
24     Subject => 'html mime',
25     Data    => <<END,
26 If you have some problems with RT you could find help
27 on <a href="http://wiki.bestpractical.com">wiki</a> 
28 or find known bugs on http://rt3.fsck.com
29
30 to test anchor:
31 https://wiki.bestpractical.com/test#anchor
32 --
33 Best regards. BestPractical Team.
34 END
35 );
36
37
38 my $ticket = RT::Ticket->new( RT->SystemUser );
39
40 my ($plain_id) = $ticket->Create(
41     Subject => 'test',
42     Queue => 'General',
43     MIMEObj => $plain,
44 );
45 ok($plain_id, "We created a ticket #$plain_id");
46
47 my ($html_id) = $ticket->Create(
48     Subject => 'test',
49     Queue => 'General',
50     MIMEObj => $html,
51 );
52 ok($html_id, "We created a ticket #$html_id");
53
54 diag 'test no clicky';
55 {
56     RT->Config->Set( 'Active_MakeClicky' => () );
57     my ( $baseurl, $m ) = RT::Test->started_ok;
58     ok $m->login, 'logged in';
59     $m->goto_ticket($plain_id);
60
61     my @links = $m->find_link(
62         tag  => 'a',
63         url  => 'http://wiki.bestpractical.com',
64     );
65     ok( @links == 0, 'no clicky link found with plain message' );
66
67     @links = $m->find_link(
68         tag  => 'a',
69         url  => 'http://rt3.fsck.com',
70     );
71     ok( @links == 0, 'no extra clicky link found with html message' );
72 }
73
74 diag 'test httpurl';
75 {
76     RT::Test->stop_server;
77     RT->Config->Set( 'Active_MakeClicky' => qw/httpurl/ );
78     my ( $baseurl, $m ) = RT::Test->started_ok;
79     ok $m->login, 'logged in';
80     $m->goto_ticket($plain_id);
81
82     my @links = $m->find_link(
83         tag  => 'a',
84         url  => 'http://wiki.bestpractical.com',
85         text => 'Open URL',
86     );
87     ok( scalar @links, 'found clicky link' );
88
89     @links = $m->find_link(
90         tag  => 'a',
91         url  => 'https://wiki.bestpractical.com/test#anchor',
92         text => 'Open URL',
93     );
94     ok( scalar @links, 'found clicky link with anchor' );
95
96     $m->goto_ticket($html_id);
97     @links = $m->find_link(
98         tag  => 'a',
99         url  => 'http://wiki.bestpractical.com',
100         text => 'Open URL',
101     );
102     ok( @links == 0, 'not make clicky links clicky twice' );
103
104     @links = $m->find_link(
105         tag  => 'a',
106         url  => 'http://rt3.fsck.com',
107         text => 'Open URL',
108     );
109     ok( scalar @links, 'found clicky link' );
110
111     @links = $m->find_link(
112         tag  => 'a',
113         url  => 'https://wiki.bestpractical.com/test#anchor',
114         text => 'Open URL',
115     );
116     ok( scalar @links, 'found clicky link with anchor' );
117 }
118
119 diag 'test httpurl_overwrite';
120 {
121     RT::Test->stop_server;
122     RT->Config->Set( 'Active_MakeClicky' => 'httpurl_overwrite' );
123     my ( $baseurl, $m ) = RT::Test->started_ok;
124     ok $m->login, 'logged in';
125     ok $m->goto_ticket($plain_id), 'opened diplay page of the ticket';
126
127     my @links = $m->find_link(
128         tag => 'a',
129         url => 'http://wiki.bestpractical.com',
130         text => 'http://wiki.bestpractical.com',
131     );
132     ok( scalar @links, 'found clicky link' );
133
134     @links = $m->find_link(
135         tag  => 'a',
136         url  => 'https://wiki.bestpractical.com/test#anchor',
137         text => 'https://wiki.bestpractical.com/test#anchor',
138     );
139     ok( scalar @links, 'found clicky link with anchor' );
140 }
141