~ubuntu-branches/ubuntu/oneiric/request-tracker3.8/oneiric-updates

« back to all changes in this revision

Viewing changes to t/ticket/sort-by-custom-ownership.t

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves, Dominic Hargreaves, Christian Perrier
  • Date: 2009-06-16 21:46:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616214659-5ji9k1n3qyc2br3n
Tags: 3.8.4-1
[ Dominic Hargreaves ]
* Add missing comma in Depends (fixes FTBFS on etch)
* Update debconf translations: pt.po, ja.po, sv.po, it.po, cs.po, ru.po
  (Closes: #519885, #519922, #520603, #520759, #521199, #521926)
* Document preference for not using SQLite in production
  (Closes: #512750)

[ Christian Perrier ]
* Debconf templates and debian/control reviewed by the debian-l10n-
  english team as part of the Smith review project.
  (Closes: #522367, #520959)
* [Debconf translation updates]
  - Japanese. Closes: #522896
  - German. Closes: #520958
  - Portuguese. Closes: #523481
  - Galician. Closes: #524256
  - Galician. Closes: #524256
  - Spanish. Closes: #524449
  - Italian. Closes: #524715
  - Russian. Closes: #524894
  - Swedish. Closes: #525171
  - French. Closes: #525281

[ Dominic Hargreaves ]
* Don't tell dbconfig to comment out unused variables, since this
  breaks MySQL and Postgres database configuration (Closes: #523090)
* Update Standards-Version (no changes)
* Switch dependency on sysklogd to rsyslog (Closes: #526914)
* New upstream release; includes
  - Minor security fix (Closes: #533069)
  - Add missing Postgres index (Closes: #512653)
* Patch webmux.pl to provide a better error message when the wrong
  major version of RT is in @INC (for example in a mod_perl context).
  (Closes: #518692)
* Add some more example Exim 4 configuration (Closes: #238345)
* Don't apply database ACLs in databases managed by dbconfig-common.
* Remove unused ACL patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use Test::More; 
 
4
plan tests => 7;
 
5
use RT;
 
6
use RT::Test;
 
7
 
 
8
 
 
9
use strict;
 
10
use warnings;
 
11
 
 
12
use RT::Tickets;
 
13
use RT::Queue;
 
14
use RT::CustomField;
 
15
 
 
16
my($ret,$msg);
 
17
 
 
18
# Test Paw Sort
 
19
 
 
20
 
 
21
 
 
22
# ---- Create a queue to test with.
 
23
my $queue = "PAWSortQueue-$$";
 
24
my $queue_obj = RT::Queue->new($RT::SystemUser);
 
25
($ret, $msg) = $queue_obj->Create(Name => $queue,
 
26
                                  Description => 'queue for custom field sort testing');
 
27
ok($ret, "$queue test queue creation. $msg");
 
28
 
 
29
 
 
30
# ---- Create some users
 
31
 
 
32
my $me = RT::User->new($RT::SystemUser);
 
33
($ret, $msg) = $me->Create(Name => "Me$$", EmailAddress => $$.'create-me-1@example.com');
 
34
($ret, $msg) = $me->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'OwnTicket');
 
35
($ret, $msg) = $me->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'SeeQueue');
 
36
($ret, $msg) = $me->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'ShowTicket');
 
37
my $you = RT::User->new($RT::SystemUser);
 
38
($ret, $msg) = $you->Create(Name => "You$$", EmailAddress => $$.'create-you-1@example.com');
 
39
($ret, $msg) = $you->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'OwnTicket');
 
40
($ret, $msg) = $you->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'SeeQueue');
 
41
($ret, $msg) = $you->PrincipalObj->GrantRight(Object =>$queue_obj, Right => 'ShowTicket');
 
42
 
 
43
my $nobody = RT::User->new($RT::SystemUser);
 
44
$nobody->Load('nobody');
 
45
 
 
46
 
 
47
# ----- Create some tickets to test with.  Assign them some values to
 
48
# make it easy to sort with.
 
49
 
 
50
my @tickets = (
 
51
               [qw[1 10], $me],
 
52
               [qw[2 20], $me],
 
53
               [qw[3 20], $you],
 
54
               [qw[4 30], $you],
 
55
               [qw[5  5], $nobody],
 
56
               [qw[6 55], $nobody],
 
57
              );
 
58
for (@tickets) {
 
59
  my $t = RT::Ticket->new($RT::SystemUser);
 
60
  $t->Create( Queue => $queue_obj->Id,
 
61
              Subject => $_->[0],
 
62
              Owner => $_->[2]->Id,
 
63
              Priority => $_->[1],
 
64
            );
 
65
}
 
66
 
 
67
sub check_order {
 
68
  my ($tx, @order) = @_;
 
69
  my @results;
 
70
  while (my $t = $tx->Next) {
 
71
    push @results, $t->Subject;
 
72
  }
 
73
  my $results = join (" ",@results);
 
74
  my $order = join(" ",@order);
 
75
  is( $results, $order );
 
76
}
 
77
 
 
78
 
 
79
# The real tests start here
 
80
 
 
81
my $cme = new RT::CurrentUser( $me );
 
82
my $metx = new RT::Tickets( $cme );
 
83
# Make sure we can sort in both directions on a queue specific field.
 
84
$metx->FromSQL(qq[queue="$queue"] );
 
85
$metx->OrderBy( FIELD => "Custom.Ownership", ORDER => 'ASC' );
 
86
is($metx->Count,6);
 
87
check_order( $metx, qw[2 1 6 5 4 3]);
 
88
 
 
89
$metx->OrderBy( FIELD => "Custom.Ownership", ORDER => 'DESC' );
 
90
is($metx->Count,6);
 
91
check_order( $metx, reverse qw[2 1 6 5 4 3]);
 
92
 
 
93
 
 
94
 
 
95
my $cyou = new RT::CurrentUser( $you );
 
96
my $youtx = new RT::Tickets( $cyou );
 
97
# Make sure we can sort in both directions on a queue specific field.
 
98
$youtx->FromSQL(qq[queue="$queue"] );
 
99
$youtx->OrderBy( FIELD => "Custom.Ownership", ORDER => 'ASC' );
 
100
is($youtx->Count,6);
 
101
check_order( $youtx, qw[4 3 6 5 2 1]);
 
102
 
 
103
__END__
 
104
 
 
105