6 use RT::Test tests => 24;
12 my $root = RT::CurrentUser->new('root');
13 ok ($root->Id, "Loaded root");
14 my $cl = RT::Class->new($root);
15 ok (UNIVERSAL::isa($cl, 'RT::Class'), "the new class is a class");
17 my ($id, $msg) = $cl->Create(Name => 'Test-'.$$, Description => 'A test class');
21 # no duplicate class names should be allowed
22 ($id, $msg) = $cl->Create(Name => 'Test-'.$$, Description => 'A test class');
26 #class name should be required
28 ($id, $msg) = $cl->Create(Name => '', Description => 'A test class');
34 $cl->Load('Test-'.$$);
35 ok($cl->id, "Loaded the class we want");
39 # Create a new user. make sure they can't create a class
41 my $u= RT::User->new(RT->SystemUser);
42 $u->Create(Name => "ArticlesTest".time, Privileged => 1);
43 ok ($u->Id, "Created a new user");
45 # Make sure you can't create a group with no acls
46 $cl = RT::Class->new($u);
47 ok (UNIVERSAL::isa($cl, 'RT::Class'), "the new class is a class");
49 ($id, $msg) = $cl->Create(Name => 'Test-nobody'.$$, Description => 'A test class');
52 ok (!$id, $msg. "- Can not create classes as a random new user - " .$u->Id);
53 $u->PrincipalObj->GrantRight(Right =>'AdminClass', Object => RT->System);
54 ($id, $msg) = $cl->Create(Name => 'Test-nobody-'.$$, Description => 'A test class');
56 ok ($id, $msg. "- Can create classes as a random new user after ACL grant");
58 # now check the Web UI
60 my ($url, $m) = RT::Test->started_ok;
62 $m->get_ok("$url/Admin/Articles/Classes/Modify.html?Create=1");
63 $m->content_contains('Create a Class', 'found title');
66 fields => { Name => 'Test Redirect' },
68 $m->content_contains('Object created', 'found results');
69 $m->content_contains('Modify the Class Test Redirect', 'found title');
71 $m->untick( 'Include-Name', 1 );
72 $m->field( 'Description', 'Test Description' );
74 $m->content_like(qr/Description changed from.*no value.*to .*Test Description/,'description changed');
76 is($m->current_form->find_input('Include-Name')->value,undef,'Disabled Including Names for this Class');