3 use RT::Test tests => undef;
5 my $queue_foo = RT::Test->load_or_create_queue( Name => 'Foo' );
6 my $queue_bar = RT::Test->load_or_create_queue( Name => 'Bar' );
7 my $queue_baz = RT::Test->load_or_create_queue( Name => 'Baz' );
8 $queue_baz->SetDisabled(1);
10 my ( $baseurl, $m ) = RT::Test->started_ok;
12 ok( $m->login, 'logged in' );
14 search_queues_ok( { query => 'id = 1' }, ['1: General'], 'search id = 1' );
17 query => 'Name = General',
19 fields => 'id,name,description'
21 [ "id\tName\tDescription", "1\tGeneral\tThe default queue" ],
22 'search by name with customized fields'
26 { query => 'id > 10' },
27 ['No matching results.'],
32 { query => 'foo = 3' },
33 ['Invalid field specification: foo'],
38 { query => 'id foo 3' },
39 ['Invalid operator specification: foo'],
44 { query => '', orderby => 'id' },
45 [ '1: General', $queue_foo->id . ': Foo', $queue_bar->id . ': Bar', ],
50 { query => '', orderby => 'name' },
51 [ $queue_bar->id . ': Bar', $queue_foo->id . ': Foo', '1: General', ],
56 { query => '', orderby => '+name' },
57 [ $queue_bar->id . ': Bar', $queue_foo->id . ': Foo', '1: General', ],
62 { query => '', orderby => '-name' },
63 [ '1: General', $queue_foo->id . ': Foo', $queue_bar->id . ': Bar', ],
68 { query => 'Disabled = 0', orderby => 'id' },
69 [ '1: General', $queue_foo->id . ': Foo', $queue_bar->id . ': Bar', ],
74 { query => 'Disabled = 1', orderby => 'id' },
75 [ $queue_baz->id . ': Baz', ],
80 { query => 'Disabled = 2', orderby => 'id' },
81 [ '2: ___Approvals', ],
82 'special Approvals queue'
85 sub search_queues_ok {
86 local $Test::Builder::Level = $Test::Builder::Level + 1;
89 my $name = shift || 'search queues';
91 my $uri = URI->new("$baseurl/REST/1.0/search/queue");
92 $uri->query_form(%$query);
95 my @lines = split /\n/, $m->content;
96 shift @lines; # header
97 shift @lines; # empty line
99 is_deeply( \@lines, $expected, $name );