[Rt-commit] r3969 - in rt/branches/CHALDEA-EXPERIMENTAL: .
html/User/Elements lib/RT lib/RT/Action lib/t/regression
jesse at bestpractical.com
jesse at bestpractical.com
Fri Oct 14 19:48:20 EDT 2005
Author: jesse
Date: Fri Oct 14 19:48:19 2005
New Revision: 3969
Added:
rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/22search_tix_by_watcher.t
Modified:
rt/branches/CHALDEA-EXPERIMENTAL/ (props changed)
rt/branches/CHALDEA-EXPERIMENTAL/html/User/Elements/Tabs
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm
Log:
r17374 at hualien: jesse | 2005-10-14 15:34:43 -0400
r17361 at hualien: jesse | 2005-10-14 15:22:39 -0400
r17358 at hualien: jesse | 2005-10-14 15:06:26 -0400
r17219 at hualien (orig r3938): robert | 2005-10-07 00:20:15 -0400
r3995 at bear: rspier | 2005-10-06 21:19:24 -0700
[fsck.com #7067] - If we can't find a customfield that the user is allowed to see on a ticket, don't return any values, (when specifying a custom field)
r17275 at hualien (orig r3944): ruz | 2005-10-10 15:27:36 -0400
backport of the 3.5-TESTING at 3943
Changes
* fix for search by owner's fields, now owner is WATCHERFIELD instead of ENUM
* added backward compatible variant for Owner, next searches should work
** Owner = '<id>'
** Owner != '<id>'
** Owner = '<name>'
** Owner != '<name>'
** for other operators or if subfield(subkey) is specified search works
as for other watchers
* Fix for searches like "Cc.Name <> 'SomeBody'", was skipping tickets
with empty Cc list.
* get rid of some unint warnings
* test suite for all corner cases
r17276 at hualien (orig r3945): ruz | 2005-10-10 15:47:29 -0400
backport of the 3.5-TESTING at 3543
Changes:
* fix attachments ordering
r17313 at hualien (orig r3948): ruz | 2005-10-10 20:01:50 -0400
* get rid of "not a number" warning
r17339 at hualien (orig r3957): ruz | 2005-10-13 08:37:47 -0400
* code comments
r17340 at hualien (orig r3958): ruz | 2005-10-13 08:40:24 -0400
* new callback in html/User/Elements/Tabs
r17360 at hualien: jesse | 2005-10-14 15:21:46 -0400
* Perltidy
Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/User/Elements/Tabs
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/User/Elements/Tabs (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/User/Elements/Tabs Fri Oct 14 19:48:19 2005
@@ -67,6 +67,9 @@
},
};
+ # Now let callbacks add their extra tabs
+ $m->comp('/Elements/Callback', tabs => $tabs, %ARGS);
+
foreach my $tab (sort keys %{$tabs}) {
if ($tabs->{$tab}->{'path'} eq $current_tab) {
$tabs->{$tab}->{"subtabs"} = $subtabs;
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Action/SendEmail.pm Fri Oct 14 19:48:19 2005
@@ -323,7 +323,7 @@
FIELD => 'TransactionId',
VALUE => $self->TransactionObj->Id
);
- $attachments->OrderBy('id');
+ $attachments->OrderBy( FIELD => 'id');
my $transaction_content_obj = $self->TransactionObj->ContentObj;
@@ -445,7 +445,7 @@
# If there is one, and we can parse it, then base our Message-ID on it
if ($msgid
- and $msgid =~ s/<(rt-.*?-\d+-\d+)\.(\d+-0-0)\@$RT::Organization>$/
+ and $msgid =~ s/<(rt-.*?-\d+-\d+)\.(\d+)-\d+-\d+\@\Q$RT::Organization\E>$/
"<$1." . $self->TicketObj->id
. "-" . $self->ScripObj->id
. "-" . $self->ScripActionObj->{_Message_ID}
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Ticket_Overlay.pm Fri Oct 14 19:48:19 2005
@@ -3483,7 +3483,7 @@
#If we can't actually set the field to the value, don't record
# a transaction. instead, get out of here.
- if ( $ret == 0 ) { return ( 0, $msg ); }
+ return ( 0, $msg ) unless $ret;
}
if ( $args{'RecordTransaction'} == 1 ) {
@@ -3726,6 +3726,10 @@
$cf->LoadByNameAndQueue( Name => $field, Queue => '0' );
}
$field = $cf->id;
+ unless ( $field =~ /^\d+$/ ) {
+ # If we didn't find a valid cfid, give up.
+ return RT::CustomFieldValues->new($self->CurrentUser);
+ }
}
return $self->SUPER::CustomFieldValues($field);
}
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm Fri Oct 14 19:48:19 2005
@@ -104,7 +104,7 @@
Type => [ 'ENUM', ],
Creator => [ 'ENUM' => 'User', ],
LastUpdatedBy => [ 'ENUM' => 'User', ],
- Owner => [ 'ENUM' => 'User', ],
+ Owner => [ 'WATCHERFIELD' => 'Owner', ],
EffectiveId => [ 'INT', ],
id => [ 'INT', ],
InitialPriority => [ 'INT', ],
@@ -135,7 +135,7 @@
Requestors => [ 'WATCHERFIELD' => 'Requestor', ],
Cc => [ 'WATCHERFIELD' => 'Cc', ],
AdminCc => [ 'WATCHERFIELD' => 'AdminCc', ],
- Watcher => [ 'WATCHERFIELD', ],
+ Watcher => ['WATCHERFIELD'],
LinkedTo => [ 'LINKFIELD', ],
CustomFieldValue => [ 'CUSTOMFIELD', ],
CF => [ 'CUSTOMFIELD', ],
@@ -160,7 +160,7 @@
LINKFIELD => \&_LinkFieldLimit,
CUSTOMFIELD => \&_CustomFieldLimit,
);
-my %can_bundle = ( WATCHERFIELD => "yeps", );
+my %can_bundle = ( WATCHERFIELD => "yes", );
# Default EntryAggregator per type
# if you specify OP, you must specify all valid OPs
@@ -793,8 +793,6 @@
my $value = shift;
my %rest = (@_);
- $self->_OpenParen;
-
# Find out what sort of watcher we're looking for
my $fieldname;
if ( ref $field ) {
@@ -802,41 +800,71 @@
}
else {
$fieldname = $field;
+ $field = [ [ $field, $op, $value, %rest ] ]; # gross hack
}
my $meta = $FIELD_METADATA{$fieldname};
my $type = ( defined $meta->[1] ? $meta->[1] : undef );
+ # Owner was ENUM field, so "Owner = 'xxx'" allowed user to
+ # search by id and Name at the same time, this is workaround
+ # to preserve backward compatibility
+ if ( $fieldname eq 'Owner' ) {
+ my $flag = 0;
+ for my $chunk ( splice @$field ) {
+ my ( $f, $op, $value, %rest ) = @$chunk;
+ if ( !$rest{SUBKEY} && $op =~ /^!?=$/ ) {
+ $self->_OpenParen unless $flag++;
+ my $o = RT::User->new( $self->CurrentUser );
+ $o->Load($value);
+ $value = $o->Id;
+ $self->_SQLLimit(
+ FIELD => 'Owner',
+ OPERATOR => $op,
+ VALUE => $value,
+ %rest,
+ );
+ }
+ else {
+ push @$field, $chunk;
+ }
+ }
+ $self->_CloseParen if $flag;
+ return unless @$field;
+ }
+
my $users = $self->_WatcherJoin($type);
# If we're looking for multiple watchers of a given type,
# TicketSQL will be handing it to us as an array of clauses in
# $field
- if ( ref $field ) { # gross hack
- $self->_OpenParen;
- for my $chunk (@$field) {
- ( $field, $op, $value, %rest ) = @$chunk;
- $self->_SQLLimit(
- ALIAS => $users,
- FIELD => $rest{SUBKEY} || 'EmailAddress',
- VALUE => $value,
- OPERATOR => $op,
- CASESENSITIVE => 0,
- %rest
- );
- }
- $self->_CloseParen;
- }
- else {
+ $self->_OpenParen;
+ for my $chunk (@$field) {
+ ( $field, $op, $value, %rest ) = @$chunk;
+ $rest{SUBKEY} ||= 'EmailAddress';
+
+ my $re_negative_op = qr[!=|NOT LIKE];
+ $self->_OpenParen if $op =~ /$re_negative_op/;
+
$self->_SQLLimit(
ALIAS => $users,
- FIELD => $rest{SUBKEY} || 'EmailAddress',
+ FIELD => $rest{SUBKEY},
VALUE => $value,
OPERATOR => $op,
CASESENSITIVE => 0,
%rest
);
- }
+ if ( $op =~ /$re_negative_op/ ) {
+ $self->_SQLLimit(
+ ALIAS => $users,
+ FIELD => $rest{SUBKEY},
+ OPERATOR => 'IS',
+ VALUE => 'NULL',
+ ENTRYAGGREGATOR => 'OR',
+ );
+ $self->_CloseParen;
+ }
+ }
$self->_CloseParen;
}
@@ -850,28 +878,28 @@
sub _WatcherJoin {
my $self = shift;
my $type = shift;
- my $key = shift || "limit";
+ # we cache joins chain per watcher type
+ # if we limit by requestor then we shouldn't join requestors again
+ # for sort or limit on other requestors
+ if ( $self->{'_watcher_join_users_alias'}{ $type || 'any' } ) {
+ return $self->{'_watcher_join_users_alias'}{ $type || 'any' };
+ }
+
+# we always have watcher groups for ticket
+# this join should be NORMAL
+# XXX: if we change this from Join to NewAlias+Limit
+# then Pg will complain because SB build wrong query.
+# Query looks like "FROM (Tickets LEFT JOIN CGM ON(Groups.id = CGM.GroupId)), Groups"
+# Pg doesn't like that fact that it doesn't know about Groups table yet when
+# join CGM table into Tickets. Problem is in Join method which doesn't use
+# ALIAS1 argument when build braces.
my $groups = $self->Join(
- TYPE => 'left',
- ALIAS1 => 'main',
- FIELD1 => 'id',
- TABLE2 => 'Groups',
- FIELD2 => 'Instance'
- );
- my $groupmembers = $self->Join(
- TYPE => 'left',
- ALIAS1 => $groups,
- FIELD1 => 'id',
- TABLE2 => 'CachedGroupMembers',
- FIELD2 => 'GroupId'
- );
- my $users = $self->Join(
- TYPE => 'left',
- ALIAS1 => $groupmembers,
- FIELD1 => 'MemberId',
- TABLE2 => 'Users',
- FIELD2 => 'id'
+ ALIAS1 => 'main',
+ FIELD1 => 'id',
+ TABLE2 => 'Groups',
+ FIELD2 => 'Instance',
+ ENTRYAGGREGATOR => 'AND'
);
$self->SUPER::Limit(
ALIAS => $groups,
@@ -886,7 +914,37 @@
ENTRYAGGREGATOR => 'AND'
)
if ($type);
- return $users;
+
+ my $groupmembers = $self->Join(
+ TYPE => 'LEFT',
+ ALIAS1 => $groups,
+ FIELD1 => 'id',
+ TABLE2 => 'CachedGroupMembers',
+ FIELD2 => 'GroupId'
+ );
+
+ # XXX: work around, we must hide groups that
+ # are members of the role group we search in,
+ # otherwise them result in wrong NULLs in Users
+ # table and break ordering. Now, we know that
+ # RT doesn't allow to add groups as members of the
+ # ticket roles, so we just hide entries in CGM table
+ # with MemberId == GroupId from results
+ my $groupmembers = $self->SUPER::Limit(
+ LEFTJOIN => $groupmembers,
+ FIELD => 'GroupId',
+ OPERATOR => '!=',
+ VALUE => "$groupmembers.MemberId",
+ QUOTEVALUE => 0,
+ );
+ my $users = $self->Join(
+ TYPE => 'LEFT',
+ ALIAS1 => $groupmembers,
+ FIELD1 => 'MemberId',
+ TABLE2 => 'Users',
+ FIELD2 => 'id'
+ );
+ return $self->{'_watcher_join_users_alias'}{ $type || 'any' } = $users;
}
=head2 _WatcherMembershipLimit
@@ -1310,11 +1368,15 @@
# If we're looking at the effective id, we don't want to append the other clause
# which limits us to tickets where id = effective id
- if ( $args{'FIELD'} eq 'EffectiveId' ) {
+ if ( $args{'FIELD'} eq 'EffectiveId'
+ && ( !$args{'ALIAS'} || $args{'ALIAS'} eq 'main' ) )
+ {
$self->{'looking_at_effective_id'} = 1;
}
- if ( $args{'FIELD'} eq 'Type' ) {
+ if ( $args{'FIELD'} eq 'Type'
+ && ( !$args{'ALIAS'} || $args{'ALIAS'} eq 'main' ) )
+ {
$self->{'looking_at_type'} = 1;
}
@@ -2532,7 +2594,7 @@
}
die "I don't know about $field yet"
- unless ( exists $FIELD_METADATA{$realfield}
+ unless ( exists $FIELDS{$realfield}
or $restriction->{CUSTOMFIELD} );
my $type = $FIELD_METADATA{$realfield}->[0];
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/Tickets_Overlay_SQL.pm Fri Oct 14 19:48:19 2005
@@ -85,11 +85,13 @@
sub _SQLLimit {
my $self = shift;
my %args = (@_);
- if ($args{'FIELD'} eq 'EffectiveId') {
+ if ($args{'FIELD'} eq 'EffectiveId' &&
+ (!$args{'ALIAS'} || $args{'ALIAS'} eq 'main' ) ) {
$self->{'looking_at_effective_id'} = 1;
}
- if ($args{'FIELD'} eq 'Type') {
+ if ($args{'FIELD'} eq 'Type' &&
+ (!$args{'ALIAS'} || $args{'ALIAS'} eq 'main' ) ) {
$self->{'looking_at_type'} = 1;
}
@@ -288,7 +290,7 @@
# print "$ea Key=[$key] op=[$op] val=[$val]\n";
- my $subkey;
+ my $subkey = '';
if ($key =~ /^(.+?)\.(.+)$/) {
$key = $1;
$subkey = $2;
@@ -377,11 +379,11 @@
my $first = 1;
# Build SQL from the data hash
- for my $data ( @{ $clauses->{$f} } ) {
- $sql .= $data->[0] unless $first; $first=0;
- $sql .= " '". $data->[2] . "' ";
- $sql .= $data->[3] . " ";
- $sql .= "'". $data->[4] . "' ";
+ for my $data ( @{ $clauses->{$f} } ) {
+ $sql .= $data->[0] unless $first; $first=0; # ENTRYAGGREGATOR
+ $sql .= " '". $data->[2] . "' "; # FIELD
+ $sql .= $data->[3] . " "; # OPERATOR
+ $sql .= "'". $data->[4] . "' "; # VALUE
}
push @sql, " ( " . $sql . " ) ";
Added: rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/22search_tix_by_watcher.t
==============================================================================
--- (empty file)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/t/regression/22search_tix_by_watcher.t Fri Oct 14 19:48:19 2005
@@ -0,0 +1,215 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+
+use Test::More qw/no_plan/;
+use_ok('RT');
+RT::LoadConfig();
+RT::Init();
+use RT::Ticket;
+
+my $q = RT::Queue->new($RT::SystemUser);
+my $queue = 'SearchTests-'.rand(200);
+$q->Create(Name => $queue);
+
+my @data = (
+ { Subject => '1', Requestor => 'bravo at example.com' },
+ { Subject => '2', Cc => 'alpha at example.com' },
+);
+
+my $total = 0;
+
+sub add_tix_from_data {
+ my @res = ();
+ while (@data) {
+ my $t = RT::Ticket->new($RT::SystemUser);
+ my ( $id, undef $msg ) = $t->Create(
+ Queue => $q->id,
+ %{ shift(@data) },
+ );
+ ok( $id, "ticket created" ) or diag("error: $msg");
+ push @res, $t;
+ $total++;
+ }
+ return @res;
+}
+add_tix_from_data();
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue'");
+ is($tix->Count, $total, "found $total tickets");
+}
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Requestor = 'bravo\@example.com'");
+ is($tix->Count, 1, "found ticket(s)");
+ is($tix->First->RequestorAddresses, 'bravo at example.com',"correct requestor");
+}
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Cc = 'alpha\@example.com'");
+ is($tix->Count, 1, "found ticket(s)");
+ is($tix->First->CcAddresses, 'alpha at example.com', "correct Cc");
+}
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND (Cc = 'alpha\@example.com' OR Requestor = 'bravo\@example.com')");
+ is($tix->Count, 2, "found ticket(s)");
+ my @mails;
+ while (my $t = $tix->Next) {
+ push @mails, $t->RequestorAddresses;
+ push @mails, $t->CcAddresses;
+ }
+ @mails = sort grep $_, @mails;
+ is_deeply(\@mails, ['alpha at example.com', 'bravo at example.com'], "correct addresses");
+}
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND (Cc = 'alpha\@example.com' AND Requestor = 'bravo\@example.com')");
+ is($tix->Count, 0, "found ticket(s)");
+}
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Cc != 'alpha\@example.com'");
+ is($tix->Count, 1, "found ticket(s)");
+ is($tix->First->RequestorAddresses, 'bravo at example.com',"correct requestor");
+}
+
+ at data = ( { Subject => '3' } );
+add_tix_from_data();
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Cc != 'alpha\@example.com'");
+ is($tix->Count, 2, "found ticket(s)");
+ my @mails;
+ while (my $t = $tix->Next) { push @mails, ($t->CcAddresses||'') }
+ is( scalar(grep 'alpha at example.com' eq $_, @mails), 0, "no tickets with non required data");
+}
+
+{
+ # has no requestor search
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Requestor IS NULL");
+ is($tix->Count, 2, "found ticket(s)");
+ my @mails;
+ while (my $t = $tix->Next) { push @mails, ($t->RequestorAddresses||'') }
+ is( scalar(grep $_, @mails), 0, "no tickets with non required data");
+}
+
+{
+ # has at least one requestor search
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Requestor IS NOT NULL");
+ is($tix->Count, 1, "found ticket(s)");
+ my @mails;
+ while (my $t = $tix->Next) { push @mails, ($t->RequestorAddresses||'') }
+ is( scalar(grep !$_, @mails), 0, "no tickets with non required data");
+}
+
+ at data = ( { Subject => '3', Requestor => 'charly at example.com' } );
+add_tix_from_data();
+
+{
+ # has no requestor search
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND
+ (Requestor = 'bravo\@example.com' OR Requestor = 'charly\@example.com')");
+ is($tix->Count, 2, "found ticket(s)");
+ my @mails;
+ while (my $t = $tix->Next) { push @mails, ($t->RequestorAddresses||'') }
+ is_deeply( [sort @mails],
+ ['bravo at example.com', 'charly at example.com'],
+ "requestor addresses are correct"
+ );
+}
+
+# owner is special watcher because reference is duplicated in two places,
+# owner was an ENUM field now it's WATCHERFIELD, but should support old
+# style ENUM searches for backward compatibility
+my $nobody = RT::Nobody();
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Owner = '". $nobody->id ."'");
+ is($tix->Count, 4, "found ticket(s)");
+}
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Owner = '". $nobody->Name ."'");
+ is($tix->Count, 4, "found ticket(s)");
+}
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Owner != '". $nobody->id ."'");
+ is($tix->Count, 0, "found ticket(s)");
+}
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Owner != '". $nobody->Name ."'");
+ is($tix->Count, 0, "found ticket(s)");
+}
+
+{
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Owner.Name LIKE 'nob'");
+ is($tix->Count, 4, "found ticket(s)");
+}
+
+{
+ # create ticket and force type to not a 'ticket' value
+ # bug #6898 at rt3.fsck.com
+ # and http://marc.theaimsgroup.com/?l=rt-devel&m=112662934627236&w=2
+ @data = ( { Subject => 'not a ticket' } );
+ my($t) = add_tix_from_data();
+ $t->_Set( Field => 'Type',
+ Value => 'not a ticket',
+ CheckACL => 0,
+ RecordTransaction => 0,
+ );
+ $total--;
+
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND Owner = 'Nobody'");
+ is($tix->Count, 4, "found ticket(s)");
+}
+
+{
+ my $everyone = RT::Group->new( $RT::SystemUser );
+ $everyone->LoadSystemInternalGroup('Everyone');
+ ok($everyone->id, "loaded 'everyone' group");
+ my($id, $msg) = $everyone->PrincipalObj->GrantRight( Right => 'OwnTicket',
+ Object => $q
+ );
+ ok($id, "granted OwnTicket right to Everyone on '$queue'") or diag("error: $msg");
+
+ my $u = RT::User->new( $RT::SystemUser );
+ $u->LoadByCols( EmailAddress => 'alpha at example.com' );
+ ok($u->id, "loaded user");
+ @data = ( { Subject => '4', Owner => $u->id } );
+ my($t) = add_tix_from_data();
+ is( $t->Owner, $u->id, "created ticket with custom owner" );
+ my $u_alpha_id = $u->id;
+
+ $u = RT::User->new( $RT::SystemUser );
+ $u->LoadByCols( EmailAddress => 'bravo at example.com' );
+ ok($u->id, "loaded user");
+ @data = ( { Subject => '5', Owner => $u->id } );
+ ($t) = add_tix_from_data();
+ is( $t->Owner, $u->id, "created ticket with custom owner" );
+ my $u_bravo_id = $u->id;
+
+ my $tix = RT::Tickets->new($RT::SystemUser);
+ $tix->FromSQL("Queue = '$queue' AND
+ ( Owner = '$u_alpha_id' OR
+ Owner = '$u_bravo_id' )"
+ );
+ is($tix->Count, 2, "found ticket(s)");
+}
+
+exit(0)
More information about the Rt-commit
mailing list