[Rt-commit] rt branch, 4.0-trunk, updated. rt-4.0.8-305-gf0e2cda
Alex Vandiver
alexmv at bestpractical.com
Thu Dec 27 00:39:27 EST 2012
The branch, 4.0-trunk has been updated
via f0e2cdaeb686d290a783bd7ef68f17f3469737a9 (commit)
via efe8bc7b153f7c29083405977444cffb9aef49ca (commit)
via db66946956d94d6229f79be1808e7f1815613ca2 (commit)
from ac2f9f9ef858efefe34075b45f1885725e2762a7 (commit)
Summary of changes:
lib/RT/Tickets.pm | 2 +-
t/ticket/search_by_queue.t | 60 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 t/ticket/search_by_queue.t
- Log -----------------------------------------------------------------
commit f0e2cdaeb686d290a783bd7ef68f17f3469737a9
Merge: ac2f9f9 efe8bc7
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Dec 27 00:30:37 2012 -0500
Merge branch '4.0/search-tickets-by-queue' into 4.0-trunk
diff --cc t/ticket/search_by_queue.t
index 0000000,e8fd5de..0327152
mode 000000,100644..100644
--- a/t/ticket/search_by_queue.t
+++ b/t/ticket/search_by_queue.t
@@@ -1,0 -1,62 +1,60 @@@
-#!/usr/bin/perl -w
-
+ use strict;
+ use warnings;
+
+ use RT::Test nodata => 1, tests => 34;
+ use RT::Ticket;
+
+ my $qa = RT::Test->load_or_create_queue( Name => 'Queue A' );
+ ok $qa && $qa->id, 'loaded or created queue';
+
+ my $qb = RT::Test->load_or_create_queue( Name => 'Queue B' );
+ ok $qb && $qb->id, 'loaded or created queue';
+
+ my @tickets = RT::Test->create_tickets(
+ {},
+ { Queue => $qa->id, Subject => 'a1', },
+ { Queue => $qa->id, Subject => 'a2', },
+ { Queue => $qb->id, Subject => 'b1', },
+ { Queue => $qb->id, Subject => 'b2', },
+ );
+
+ run_tests( \@tickets,
+ 'Queue = "Queue A"' => { a1 => 1, a2 => 1, b1 => 0, b2 => 0 },
+ 'Queue = '. $qa->id => { a1 => 1, a2 => 1, b1 => 0, b2 => 0 },
+ 'Queue != "Queue A"' => { a1 => 0, a2 => 0, b1 => 1, b2 => 1 },
+ 'Queue != '. $qa->id => { a1 => 0, a2 => 0, b1 => 1, b2 => 1 },
+
+ 'Queue = "Queue B"' => { a1 => 0, a2 => 0, b1 => 1, b2 => 1 },
+ 'Queue = '. $qb->id => { a1 => 0, a2 => 0, b1 => 1, b2 => 1 },
+ 'Queue != "Queue B"' => { a1 => 1, a2 => 1, b1 => 0, b2 => 0 },
+ 'Queue != '. $qb->id => { a1 => 1, a2 => 1, b1 => 0, b2 => 0 },
+
+ 'Queue = "Bad Queue"' => { a1 => 0, a2 => 0, b1 => 0, b2 => 0 },
+ 'Queue != "Bad Queue"' => { a1 => 1, a2 => 1, b1 => 1, b2 => 1 },
+ );
+
+ sub run_tests {
+ my @tickets = @{ shift() };
+ my %test = @_;
+ my $query_prefix = join ' OR ', map 'id = '. $_->id, @tickets;
+ foreach my $key ( sort keys %test ) {
+ my $tix = RT::Tickets->new(RT->SystemUser);
+ $tix->FromSQL( "( $query_prefix ) AND ( $key )" );
+
+ my $error = 0;
+
+ my $count = 0;
+ $count++ foreach grep $_, values %{ $test{$key} };
+ is($tix->Count, $count, "found correct number of ticket(s) by '$key'") or $error = 1;
+
+ my $good_tickets = 1;
+ while ( my $ticket = $tix->Next ) {
+ next if $test{$key}->{ $ticket->Subject };
+ diag $ticket->Subject ." ticket has been found when it's not expected";
+ $good_tickets = 0;
+ }
+ ok( $good_tickets, "all tickets are good with '$key'" ) or $error = 1;
+
+ diag "Wrong SQL query for '$key':". $tix->BuildSelectQuery if $error;
+ }
+ }
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list