This commit was generated by cvs2svn to compensate for changes in r9232,
[freeside.git] / rt / t / clicky.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use RT::Test tests => 14;
7 my %clicky;
8
9 BEGIN {
10
11     %clicky = map { $_ => 1 } grep $_, RT->Config->Get('Active_MakeClicky');
12
13 # this's hack: we have to use RT::Test first to get RT->Config work, this
14 # results in the fact that we can't plan any more
15     unless ( keys %clicky ) {
16       SKIP: {
17             skip "No active Make Clicky actions", 14;
18         }
19         exit 0;
20     }
21 }
22
23 my ($baseurl, $m) = RT::Test->started_ok;
24
25 use_ok('MIME::Entity');
26
27 my $CurrentUser = $RT::SystemUser;
28
29 my $queue = new RT::Queue($CurrentUser);
30 $queue->Load('General') || Abort(loc("Queue could not be loaded."));
31
32 my $message = MIME::Entity->build(
33     Subject => 'test',
34     Data    => <<END,
35 If you have some problems with RT you could find help
36 on http://wiki.bestpractical.com or subscribe to
37 the rt-users\@lists.bestpractical.com.
38
39 --
40 Best regards. BestPractical Team.
41 END
42 );
43
44 my $ticket = new RT::Ticket( $CurrentUser );
45 my ($id) = $ticket->Create(
46     Subject => 'test',
47     Queue => $queue->Id,
48     MIMEObj => $message,
49 );
50 ok($id, "We created a ticket #$id");
51 ok($ticket->Transactions->First->Content, "Has some content");
52
53 ok $m->login, 'logged in';
54 ok $m->goto_ticket($id), 'opened diplay page of the ticket';
55
56 SKIP: {
57     skip "httpurl action disabled", 1 unless $clicky{'httpurl'};
58     my @links = $m->find_link(
59         tag => 'a',
60         url => 'http://wiki.bestpractical.com',
61         text => 'Open URL',
62     );
63     ok( scalar @links, 'found clicky link' );
64 }
65
66 SKIP: {
67     skip "httpurl_overwrite action disabled", 1 unless $clicky{'httpurl_overwrite'};
68     my @links = $m->find_link(
69         tag => 'a',
70         url => 'http://wiki.bestpractical.com',
71         text => 'http://wiki.bestpractical.com',
72     );
73     ok( scalar @links, 'found clicky link' );
74 }
75
76 {
77
78 my $message = MIME::Entity->build(
79     Type    => 'text/html',
80     Subject => 'test',
81     Data    => <<END,
82 If you have some problems with RT you could find help
83 on <a href="http://wiki.bestpractical.com">wiki</a> 
84 or find known bugs on http://rt3.fsck.com
85 --
86 Best regards. BestPractical Team.
87 END
88 );
89
90 my $ticket = new RT::Ticket($CurrentUser);
91 my ($id) = $ticket->Create(
92     Subject => 'test',
93     Queue   => $queue->Id,
94     MIMEObj => $message,
95 );
96 ok( $id,                                   "We created a ticket #$id" );
97 ok( $ticket->Transactions->First->Content, "Has some content" );
98
99 ok $m->login, 'logged in';
100 ok $m->goto_ticket($id), 'opened diplay page of the ticket';
101
102 SKIP: {
103     skip "httpurl action disabled", 2 unless $clicky{'httpurl'};
104     my @links = $m->find_link(
105         tag  => 'a',
106         url  => 'http://wiki.bestpractical.com',
107         text => 'Open URL',
108     );
109     ok( @links == 0, 'not make clicky links clicky twice' );
110
111     @links = $m->find_link(
112         tag  => 'a',
113         url  => 'http://rt3.fsck.com',
114         text => 'Open URL',
115     );
116     ok( scalar @links, 'found clicky link' );
117 }
118
119 }