[Rt-commit] r2059 - in rt/branches/3.4-RELEASE: . lib/RT
lib/t/regression sbin
jesse at bestpractical.com
jesse at bestpractical.com
Sat Jan 8 18:44:04 EST 2005
Author: jesse
Date: Sat Jan 8 18:44:03 2005
New Revision: 2059
Added:
rt/branches/3.4-RELEASE/lib/t/regression/13-attribute-tests.t
Modified:
rt/branches/3.4-RELEASE/ (props changed)
rt/branches/3.4-RELEASE/README
rt/branches/3.4-RELEASE/lib/RT/Attributes_Overlay.pm
rt/branches/3.4-RELEASE/lib/RT/Record.pm
rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in
Log:
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/3.4-RELEASE/README
==============================================================================
--- rt/branches/3.4-RELEASE/README (original)
+++ rt/branches/3.4-RELEASE/README Sat Jan 8 18:44:03 2005
@@ -57,7 +57,7 @@
Jesse Vincent
Best Practical Solutions, LLC
- June 2004
+ January, 2005
REQUIRED PACKAGES:
Modified: rt/branches/3.4-RELEASE/lib/RT/Attributes_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Attributes_Overlay.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Attributes_Overlay.pm Sat Jan 8 18:44:03 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/3.4-RELEASE/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Record.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/Record.pm Sat Jan 8 18:44:03 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/3.4-RELEASE/lib/t/regression/13-attribute-tests.t
==============================================================================
--- (empty file)
+++ rt/branches/3.4-RELEASE/lib/t/regression/13-attribute-tests.t Sat Jan 8 18:44:03 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/3.4-RELEASE/sbin/rt-test-dependencies.in
==============================================================================
--- rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in (original)
+++ rt/branches/3.4-RELEASE/sbin/rt-test-dependencies.in Sat Jan 8 18:44:03 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