4 use RT::Test tests => 26;
5 $RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
7 my ($baseurl, $m) = RT::Test->started_ok;
9 use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif';
10 use constant ImageFileContent => RT::Test->file_content(ImageFile);
12 ok $m->login, 'logged in';
14 diag "Create a CF" if $ENV{'TEST_VERBOSE'};
16 $m->follow_link( text => 'Configuration' );
17 $m->title_is(q/RT Administration/, 'admin screen');
18 $m->follow_link( text => 'Custom Fields' );
19 $m->title_is(q/Select a Custom Field/, 'admin-cf screen');
20 $m->follow_link( text => 'Create' );
22 form_name => "ModifyCustomField",
24 TypeComposite => 'Image-0',
25 LookupType => 'RT::Queue-RT::Ticket',
32 diag "apply the CF to General queue" if $ENV{'TEST_VERBOSE'};
33 my ( $cf, $cfid, $tid );
35 $m->title_is(q/Created CustomField img/, 'admin-cf created');
36 $m->follow_link( text => 'Queues' );
37 $m->title_is(q/Admin queues/, 'admin-queues screen');
38 $m->follow_link( text => 'General' );
39 $m->title_is(q/Editing Configuration for queue General/, 'admin-queue: general');
40 $m->follow_link( text => 'Ticket Custom Fields' );
42 $m->title_is(q/Edit Custom Fields for General/, 'admin-queue: general cfid');
43 $m->form_name('EditCustomFields');
45 # Sort by numeric IDs in names
46 my @names = map { $_->[1] }
47 sort { $a->[0] <=> $b->[0] }
48 map { /Object-1-CF-(\d+)/ ? [ $1 => $_ ] : () }
49 grep defined, map $_->name, $m->current_form->inputs;
51 $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
53 $m->field( $cf => 1 ); # Associate the new CF with this queue
54 $m->field( $_ => undef ) for @names; # ...and not any other. ;-)
57 $m->content_like( qr/Object created/, 'TCF added to the queue' );
60 my $tester = RT::Test->load_or_create_user( Name => 'tester', Password => '123456' );
62 { Principal => $tester->PrincipalObj,
63 Right => [qw(SeeQueue ShowTicket CreateTicket)],
66 ok $m->login( $tester->Name, 123456), 'logged in';
68 diag "check that we have no the CF on the create"
69 ." ticket page when user has no SeeCustomField right"
70 if $ENV{'TEST_VERBOSE'};
73 form_name => "CreateTicketInQueue",
74 fields => { Queue => 'General' },
76 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
78 my $form = $m->form_name("TicketCreate");
79 my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
80 ok !$form->find_input( $upload_field ), 'no form field on the page';
83 form_name => "TicketCreate",
84 fields => { Subject => 'test' },
86 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
88 $m->content_unlike(qr/img:/, 'has no img field on the page');
89 $m->follow_link( text => 'Custom Fields');
90 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
94 { Principal => $tester->PrincipalObj,
95 Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField)],
99 diag "check that we have no the CF on the create"
100 ." ticket page when user has no ModifyCustomField right"
101 if $ENV{'TEST_VERBOSE'};
104 form_name => "CreateTicketInQueue",
105 fields => { Queue => 'General' },
107 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
109 my $form = $m->form_name("TicketCreate");
110 my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
111 ok !$form->find_input( $upload_field ), 'no form field on the page';
114 form_name => "TicketCreate",
115 fields => { Subject => 'test' },
117 $tid = $1 if $m->content =~ /Ticket (\d+) created/i;
118 ok $tid, "a ticket is created succesfully";
120 $m->follow_link( text => 'Custom Fields' );
121 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
122 $form = $m->form_number(3);
123 $upload_field = "Object-RT::Ticket-$tid-CustomField-$cfid-Upload";
124 ok !$form->find_input( $upload_field ), 'no form field on the page';
127 RT::Test->set_rights(
128 { Principal => $tester->PrincipalObj,
129 Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField ModifyCustomField)],
133 diag "create a ticket with an image" if $ENV{'TEST_VERBOSE'};
136 form_name => "CreateTicketInQueue",
137 fields => { Queue => 'General' },
139 $m->content_like(qr/Upload multiple images/, 'has a upload image field');
141 $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
142 my $upload_field = "Object-RT::Ticket--CustomField-$1-Upload";
145 form_name => "TicketCreate",
147 $upload_field => ImageFile,
148 Subject => 'testing img cf creation',
152 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
154 $tid = $1 if $m->content =~ /Ticket (\d+) created/;
156 $m->title_like(qr/testing img cf creation/, "its title is the Subject");
158 $m->follow_link( text => 'bplogo.gif' );
159 $m->content_is(ImageFileContent, "it links to the uploaded image");
162 $m->get( $m->rt_base_url );
163 $m->follow_link( text => 'Tickets' );
164 $m->follow_link( text => 'New Query' );
166 $m->title_is(q/Query Builder/, 'Query building');
168 form_name => "BuildQuery",
172 ValueOfQueue => 'General',
174 button => 'AddClause',
177 $m->form_name('BuildQuery');
179 my $col = ($m->current_form->find_input('SelectDisplayColumns'))[-1];
180 $col->value( ($col->possible_values)[-1] );
184 $m->form_name('BuildQuery');
185 $m->click('DoSearch');
187 $m->follow_link( text_regex => qr/bplogo\.gif/ );
188 $m->content_is(ImageFileContent, "it links to the uploaded image");
191 [FC] Bulk Update does not have custom fields.