[Rt-commit] r12613 - in rt/branches/3.8-TESTING: . t/ticket
alexmv at bestpractical.com
alexmv at bestpractical.com
Wed May 21 17:35:08 EDT 2008
Author: alexmv
Date: Wed May 21 17:35:07 2008
New Revision: 12613
Modified:
rt/branches/3.8-TESTING/ (props changed)
rt/branches/3.8-TESTING/lib/RT/Link_Overlay.pm
rt/branches/3.8-TESTING/t/ticket/linking.t
Log:
r32064 at kohr-ah: chmrr | 2008-05-21 17:34:53 -0400
* Apply rt3.fsck.com #7405 from Todd Chapman
Modified: rt/branches/3.8-TESTING/lib/RT/Link_Overlay.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Link_Overlay.pm (original)
+++ rt/branches/3.8-TESTING/lib/RT/Link_Overlay.pm Wed May 21 17:35:07 2008
@@ -129,18 +129,20 @@
if ( $base->IsLocal ) {
- unless (UNIVERSAL::can($base->Object, 'Id')) {
+ my $object = $base->Object;
+ unless (UNIVERSAL::can($object, 'Id')) {
return (undef, $self->loc("[_1] appears to be a local object, but can't be found in the database", $args{'Base'}));
}
- $base_id = $base->Object->Id;
+ $base_id = $object->Id if UNIVERSAL::isa($object, 'RT::Ticket');
}
if ( $target->IsLocal ) {
- unless (UNIVERSAL::can($target->Object, 'Id')) {
+ my $object = $target->Object;
+ unless (UNIVERSAL::can($object, 'Id')) {
return (undef, $self->loc("[_1] appears to be a local object, but can't be found in the database", $args{'Target'}));
}
- $target_id = $target->Object->Id;
+ $target_id = $object->Id if UNIVERSAL::isa($object, 'RT::Ticket');
}
# {{{ We don't want references to ourself
Modified: rt/branches/3.8-TESTING/t/ticket/linking.t
==============================================================================
--- rt/branches/3.8-TESTING/t/ticket/linking.t (original)
+++ rt/branches/3.8-TESTING/t/ticket/linking.t Wed May 21 17:35:07 2008
@@ -1,4 +1,4 @@
-use Test::More tests => '89';
+use Test::More tests => '101';
use strict;
use warnings;
@@ -308,6 +308,65 @@
}
+my $link = RT::Link->new( $RT::SystemUser );
+($id,$msg) = $link->Create( Base => $ticket->URI, Target => $ticket2->URI, Type => 'MyLinkType' );
+ok($id, $msg);
+ok($link->LocalBase == $ticket->id, "LocalBase set correctly");
+ok($link->LocalTarget == $ticket2->id, "LocalTarget set correctly");
+
+*RT::NotTicket::Id = sub { return $$ };
+*RT::NotTicket::id = &RT::NotTicket::Id;
+
+{
+ package RT::URI::not_ticket;
+ use RT::URI::base;
+ use vars qw(@ISA);
+ @ISA = qw/RT::URI::base/;
+ sub IsLocal { 1; }
+ sub Object { return bless {}, 'RT::NotTicket'; }
+}
+
+my $orig_getresolver = \&RT::URI::_GetResolver;
+
+ *RT::URI::_GetResolver = sub {
+ my $self = shift;
+ my $scheme = shift;
+
+ $scheme =~ s/(\.|-)/_/g;
+ my $resolver;
+ my $module = "RT::URI::$scheme";
+ $resolver = $module->new($self->CurrentUser);
+
+ if ($resolver) {
+ $self->{'resolver'} = $resolver;
+ } else {
+ $self->{'resolver'} = RT::URI::base->new($self->CurrentUser);
+ }
+ };
+
+($id,$msg) = $link->Create( Base => "not_ticket::$RT::Organization/notticket/$$", Target => $ticket2->URI, Type => 'MyLinkType' );
+ok($id, $msg);
+ok($link->LocalBase == 0, "LocalBase set correctly");
+ok($link->LocalTarget == $ticket2->id, "LocalTarget set correctly");
+
+($id,$msg) = $link->Create( Target => "not_ticket::$RT::Organization/notticket/$$", Base => $ticket->URI, Type => 'MyLinkType' );
+ok($id, $msg);
+ok($link->LocalTarget == 0, "LocalTarget set correctly");
+ok($link->LocalBase == $ticket->id, "LocalBase set correctly");
+
+($id,$msg) = $link->Create(
+ Target => "not_ticket::$RT::Organization/notticket/1$$",
+ Base => "not_ticket::$RT::Organization/notticket/$$",
+ Type => 'MyLinkType' );
+
+ok($id, $msg);
+ok($link->LocalTarget == 0, "LocalTarget set correctly");
+ok($link->LocalBase == 0, "LocalBase set correctly");
+
+# restore _GetResolver
+*RT::URI::_GetResolver = $orig_getresolver;
+
+
sub link_count {
my $file = shift;
open my $fh, "<$file" or die "couldn't open $file";
More information about the Rt-commit
mailing list