File: role_groups.t

package info (click to toggle)
request-tracker4 4.4.7%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 62,888 kB
  • sloc: javascript: 130,444; perl: 65,442; sh: 1,350; makefile: 480; python: 37; php: 30
file content (35 lines) | stat: -rw-r--r-- 1,202 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
use warnings;

use RT::Test tests => undef;

my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket' );

RT::Test->db_is_valid;

my $groups_table = RT::Group->can('QuotedTableName') ? RT::Group->QuotedTableName('Groups') : 'Groups';

$RT::Handle->dbh->do("DELETE FROM $groups_table where Domain IN ('RT::Queue-Role', 'RT::Ticket-Role')");
DBIx::SearchBuilder::Record::Cachable->FlushCache;

for my $object ( $ticket, $ticket->QueueObj ) {
    for my $type (qw/Requestor AdminCc Cc Owner/) {
        ok( !$object->RoleGroup($type)->id, "Deleted group $type for " . ref $object );
    }
}

my ( $ecode, $res ) = RT::Test->run_validator( resolve => 1 );
isnt( $ecode, 0, 'non-zero exit code' );

like( $res, qr/Queues references a nonexistent record in Groups/,  'Found/Fixed error of Queues <-> Role Groups' );
like( $res, qr/Tickets references a nonexistent record in Groups/, 'Found/Fixed error of Tickets <-> Role Groups' );

RT::Test->db_is_valid;

for my $object ( $ticket, $ticket->QueueObj ) {
    for my $type (qw/Requestor AdminCc Cc Owner/) {
        ok( $object->RoleGroup($type)->id, "Recreated group $type for " . ref $object );
    }
}

done_testing;