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 = sort grep defined,
47 $m->current_form->find_input('AddCustomField')->possible_values;
49 $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
51 $m->tick( AddCustomField => $cf => 1 ); # Associate the new CF with this queue
52 $m->tick( AddCustomField => $_ => 0 ) for @names; # ...and not any other. ;-)
53 $m->click('UpdateCFs');
55 $m->content_like( qr/Object created/, 'TCF added to the queue' );
58 my $tester = RT::Test->load_or_create_user( Name => 'tester', Password => '123456' );
60 { Principal => $tester->PrincipalObj,
61 Right => [qw(SeeQueue ShowTicket CreateTicket)],
64 ok $m->login( $tester->Name, 123456), 'logged in';
66 diag "check that we have no the CF on the create"
67 ." ticket page when user has no SeeCustomField right"
68 if $ENV{'TEST_VERBOSE'};
71 form_name => "CreateTicketInQueue",
72 fields => { Queue => 'General' },
74 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
76 my $form = $m->form_name("TicketCreate");
77 my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
78 ok !$form->find_input( $upload_field ), 'no form field on the page';
81 form_name => "TicketCreate",
82 fields => { Subject => 'test' },
84 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
86 $m->content_unlike(qr/img:/, 'has no img field on the page');
87 $m->follow_link( text => 'Custom Fields');
88 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
92 { Principal => $tester->PrincipalObj,
93 Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField)],
97 diag "check that we have no the CF on the create"
98 ." ticket page when user has no ModifyCustomField right"
99 if $ENV{'TEST_VERBOSE'};
102 form_name => "CreateTicketInQueue",
103 fields => { Queue => 'General' },
105 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
107 my $form = $m->form_name("TicketCreate");
108 my $upload_field = "Object-RT::Ticket--CustomField-$cfid-Upload";
109 ok !$form->find_input( $upload_field ), 'no form field on the page';
112 form_name => "TicketCreate",
113 fields => { Subject => 'test' },
115 $tid = $1 if $m->content =~ /Ticket (\d+) created/i;
116 ok $tid, "a ticket is created succesfully";
118 $m->follow_link( text => 'Custom Fields' );
119 $m->content_unlike(qr/Upload multiple images/, 'has no upload image field');
120 $form = $m->form_number(3);
121 $upload_field = "Object-RT::Ticket-$tid-CustomField-$cfid-Upload";
122 ok !$form->find_input( $upload_field ), 'no form field on the page';
125 RT::Test->set_rights(
126 { Principal => $tester->PrincipalObj,
127 Right => [qw(SeeQueue ShowTicket CreateTicket SeeCustomField ModifyCustomField)],
131 diag "create a ticket with an image" if $ENV{'TEST_VERBOSE'};
134 form_name => "CreateTicketInQueue",
135 fields => { Queue => 'General' },
137 $m->content_like(qr/Upload multiple images/, 'has a upload image field');
139 $cf =~ /(\d+)$/ or die "Hey this is impossible dude";
140 my $upload_field = "Object-RT::Ticket--CustomField-$1-Upload";
143 form_name => "TicketCreate",
145 $upload_field => ImageFile,
146 Subject => 'testing img cf creation',
150 $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
152 $tid = $1 if $m->content =~ /Ticket (\d+) created/;
154 $m->title_like(qr/testing img cf creation/, "its title is the Subject");
156 $m->follow_link( text => 'bplogo.gif' );
157 $m->content_is(ImageFileContent, "it links to the uploaded image");
160 $m->get( $m->rt_base_url );
161 $m->follow_link( text => 'Tickets' );
162 $m->follow_link( text => 'New Query' );
164 $m->title_is(q/Query Builder/, 'Query building');
166 form_name => "BuildQuery",
170 ValueOfQueue => 'General',
172 button => 'AddClause',
175 $m->form_name('BuildQuery');
177 my $col = ($m->current_form->find_input('SelectDisplayColumns'))[-1];
178 $col->value( ($col->possible_values)[-1] );
182 $m->form_name('BuildQuery');
183 $m->click('DoSearch');
185 $m->follow_link( text_regex => qr/bplogo\.gif/ );
186 $m->content_is(ImageFileContent, "it links to the uploaded image");
189 [FC] Bulk Update does not have custom fields.