8 use RT::Test tests => '17';
11 # validate that when merging two tickets, the comments from both tickets
12 # are integrated into the new ticket
14 my $queue = RT::Queue->new($RT::SystemUser);
15 my ($id,$msg) = $queue->Create(Name => 'MergeTest-'.rand(25));
18 my $t1 = RT::Ticket->new($RT::SystemUser);
19 my ($tid,$transid, $t1msg) =$t1->Create ( Queue => $queue->Name, Subject => 'Merge test. orig');
21 ($id, $msg) = $t1->Comment(Content => 'This is a Comment on the original');
24 my $txns = $t1->Transactions;
26 while (my $txn = $txns->Next) {
27 $Comments++ if ($txn->Type eq 'Comment');
29 is($Comments,1, "our first ticket has only one Comment");
31 my $t2 = RT::Ticket->new($RT::SystemUser);
32 my ($t2id,$t2transid, $t2msg) =$t2->Create ( Queue => $queue->Name, Subject => 'Merge test. duplicate');
37 ($id, $msg) = $t2->Comment(Content => 'This is a commet on the duplicate');
41 $txns = $t2->Transactions;
43 while (my $txn = $txns->Next) {
44 $Comments++ if ($txn->Type eq 'Comment');
46 is($Comments,1, "our second ticket has only one Comment");
48 ($id, $msg) = $t1->Comment(Content => 'This is a second Comment on the original');
51 $txns = $t1->Transactions;
53 while (my $txn = $txns->Next) {
54 $Comments++ if ($txn->Type eq 'Comment');
56 is($Comments,2, "our first ticket now has two Comments");
58 ($id,$msg) = $t2->MergeInto($t1->id);
61 $txns = $t1->Transactions;
63 while (my $txn = $txns->Next) {
64 $Comments++ if ($txn->Type eq 'Comment');
66 is($Comments,3, "our first ticket now has three Comments - we merged safely");
69 # when you try to merge duplicate links on postgres, eveyrything goes to hell due to referential integrity constraints.
71 my $t = RT::Ticket->new($RT::SystemUser);
72 $t->Create(Subject => 'Main', Queue => 'general');
75 my $t2 = RT::Ticket->new($RT::SystemUser);
76 $t2->Create(Subject => 'Second', Queue => 'general');
79 my $t3 = RT::Ticket->new($RT::SystemUser);
80 $t3->Create(Subject => 'Third', Queue => 'general');
85 ($id,$val) = $t->AddLink(Type => 'DependsOn', Target => $t3->id);
87 ($id,$val) = $t2->AddLink(Type => 'DependsOn', Target => $t3->id);
90 ($id,$val) = $t->MergeInto($t2->id);