Merge branch 'master' of https://github.com/jgoodman/Freeside
[freeside.git] / rt / t / web / articles-links.t
1 use strict;
2 use warnings;
3
4 use RT::Test tests => 18;
5
6 RT->Config->Set( MasonLocalComponentRoot => RT::Test::get_abs_relocatable_dir('html') );
7
8 my ($baseurl, $m) = RT::Test->started_ok;
9
10 my $queue = RT::Queue->new(RT->SystemUser);
11 $queue->Load('General');
12
13 my $class = RT::Class->new(RT->SystemUser);
14 my ($ok, $msg) = $class->Create(Name => "issues");
15 ok($ok, "created class: $msg");
16
17 ($ok, $msg) = $class->AddToObject($queue);
18 ok($ok, "applied class to General: $msg");
19
20 my $article = RT::Article->new(RT->SystemUser);
21 ($ok, $msg) = $article->Create(Name => "instance of ticket #17421", Class => $class->id);
22 ok($ok, "created article: $msg");
23
24 ok($m->login, "logged in");
25
26 my $ticket = RT::Test->create_ticket(Queue => $queue->Id, Subject => 'oh wow! an AUTOLOAD bug');
27
28 $m->goto_ticket($ticket->id);
29 $m->follow_link_ok({text => 'Reply'});
30
31 $m->form_name('TicketUpdate');
32 $m->field('Articles-Include-Article-Named' => $article->Name);
33 $m->submit;
34
35 $m->content_contains('instance of ticket #17421', 'got the name of the article in the ticket');
36
37 # delete RT::Article's Name method on the server so we'll need to AUTOLOAD it
38 my $clone = $m->clone;
39 $clone->get_ok('/delete-article-name-method.html');
40 like($clone->content, qr/\{deleted\}/);
41
42 $m->form_name('TicketUpdate');
43 $m->click('SubmitTicket');
44
45 $m->follow_link_ok({text => 'Links'});
46
47 $m->text_contains('Article ' . $article->id . ': instance of ticket #17421', 'Article appears with its name in the links table');
48
49 my $refers_to = $ticket->RefersTo;
50 is($refers_to->Count, 1, 'the ticket has a refers-to link');
51 is($refers_to->First->TargetURI->URI, 'fsck.com-article://example.com/article/' . $article->Id, 'when we included the article it created a refers-to');
52