[Rt-commit] r2101 - in rt/branches/PLATANO-EXPERIMENTAL: . lib/RT
lib/t/regression sbin
jesse at bestpractical.com
jesse at bestpractical.com
Fri Jan 14 03:58:07 EST 2005
Author: jesse
Date: Fri Jan 14 03:58:07 2005
New Revision: 2101
Added:
rt/branches/PLATANO-EXPERIMENTAL/lib/t/regression/13-attribute-tests.t
Modified:
rt/branches/PLATANO-EXPERIMENTAL/ (props changed)
rt/branches/PLATANO-EXPERIMENTAL/README
rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Attributes_Overlay.pm
rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Record.pm
rt/branches/PLATANO-EXPERIMENTAL/sbin/rt-test-dependencies.in
Log:
r2641 at hualien (orig r2059): jesse | 2005-01-08T23:44:03.920051Z
r2640 at hualien: jesse | 2005-01-08T23:32:05.453370Z
Kevin Chen reported issues with Attributes not being properly deleted from the
ticket update screen. Alex Vandiver wrote new tests to illustrate the behaviour.
This unearthed bugs in RT's attribute handling as well as DBIx::SearchBuilder.
Modified: rt/branches/PLATANO-EXPERIMENTAL/README
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/README (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/README Fri Jan 14 03:58:07 2005
@@ -57,7 +57,7 @@
Jesse Vincent
Best Practical Solutions, LLC
- June 2004
+ January, 2005
REQUIRED PACKAGES:
Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Attributes_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Attributes_Overlay.pm (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Attributes_Overlay.pm Fri Jan 14 03:58:07 2005
@@ -56,29 +56,6 @@
=head1 METHODS
-
-=begin testing
-
-ok(require RT::Attributes);
-
-my $root = RT::User->new($RT::SystemUser);
-ok (UNIVERSAL::isa($root, 'RT::User'));
-$root->Load('root');
-ok($root->id, "Found a user for root");
-
-my $attr = $root->Attributes;
-
-ok (UNIVERSAL::isa($attr,'RT::Attributes'), 'got the attributes object');
-
-my ($id, $msg) = $root->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content');
-ok ($id, $msg);
-my @names = $attr->Names;
-
-is ($names[0] , 'TestAttr');
-
-
-=end testing
-
=cut
@@ -178,13 +155,17 @@
Content => undef,
id => undef,
@_);
-
+ my $found = 0;
foreach my $attr ($self->Named($args{'Name'})){
- $attr->Delete
- if (!defined $args{'id'} and !defined $args{'Content'})
- or (defined $args{'id'} and $attr->id eq $args{'id'})
- or (defined $args{'Content'} and $attr->Content eq $args{'Content'});
+ if ((!defined $args{'id'} and !defined $args{'Content'})
+ or (defined $args{'id'} and $attr->id eq $args{'id'})
+ or (defined $args{'Content'} and $attr->Content eq $args{'Content'})) {
+ my ($id, $msg) = $attr->Delete;
+ return ($id, $msg) unless $id;
+ $found = 1;
+ }
}
+ return (0, "No entry found") unless $found;
$self->_DoSearch();
return (1, $self->loc('Attribute Deleted'));
}
Modified: rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Record.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Record.pm (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/RT/Record.pm Fri Jan 14 03:58:07 2005
@@ -162,7 +162,9 @@
Description => $args{'Description'},
Content => $args{'Content'} );
- $self->Attributes->RedoSearch;
+
+ # XXX TODO: Why won't RedoSearch work here?
+ $self->Attributes->_DoSearch;
return ($id, $msg);
}
Added: rt/branches/PLATANO-EXPERIMENTAL/lib/t/regression/13-attribute-tests.t
==============================================================================
--- (empty file)
+++ rt/branches/PLATANO-EXPERIMENTAL/lib/t/regression/13-attribute-tests.t Fri Jan 14 03:58:07 2005
@@ -0,0 +1,67 @@
+
+use Test::More qw/no_plan/;
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+
+my $runid = rand(200);
+
+my $attribute = "squelch-$runid";
+
+ok(require RT::Attributes);
+
+my $user = RT::User->new($RT::SystemUser);
+ok (UNIVERSAL::isa($user, 'RT::User'));
+my ($id,$msg) = $user->Create(Name => 'attrtest-'.$runid);
+ok ($id, $msg);
+ok($user->id, "Created a test user");
+
+ok(1, $user->Attributes->BuildSelectQuery);
+my $attr = $user->Attributes;
+
+ok(1, $attr->BuildSelectQuery);
+
+
+ok (UNIVERSAL::isa($attr,'RT::Attributes'), 'got the attributes object');
+
+($id, $msg) = $user->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content');
+ok ($id, $msg);
+is ($attr->Count,1, " One attr after adidng a first one");
+($id, $msg) = $attr->DeleteEntry(Name => $runid);
+ok(!$id, "Deleted non-existant entry - $msg");
+is ($attr->Count,1, "1 attr after deleting an empty attr");
+
+my @names = $attr->Names;
+is ("@names", "TestAttr");
+
+
+($id, $msg) = $user->AddAttribute(Name => $runid, Content => "First");
+
+is ($attr->Count,2, " Two attrs after adding an attribute named $runid");
+($id, $msg) = $user->AddAttribute(Name => $runid, Content => "Second");
+ok($id, $msg);
+
+is ($attr->Count,3, " Three attrs after adding a secondvalue to $runid");
+($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "First");
+ok($id, $msg);
+is ($attr->Count,2);
+
+#$attr->_DoSearch();
+($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "Second");
+ok($id, $msg);
+is ($attr->Count,1);
+
+#$attr->_DoSearch();
+ok(1, $attr->BuildSelectQuery);
+($id, $msg) = $attr->DeleteEntry(Name => "moose");
+ok(!$id, "Deleted non-existant entry - $msg");
+is ($attr->Count,1);
+
+ok(1, $attr->BuildSelectQuery);
+ at names = $attr->Names;
+is("@names", "TestAttr");
+
+
+
+1;
Modified: rt/branches/PLATANO-EXPERIMENTAL/sbin/rt-test-dependencies.in
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL/sbin/rt-test-dependencies.in (original)
+++ rt/branches/PLATANO-EXPERIMENTAL/sbin/rt-test-dependencies.in Fri Jan 14 03:58:07 2005
@@ -122,7 +122,7 @@
DBI 1.37
Test::Inline
Class::ReturnValue 0.40
-DBIx::SearchBuilder 1.16
+DBIx::SearchBuilder 1.19
Text::Template
File::Spec 0.8
HTML::Entities
More information about the Rt-commit
mailing list