diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-02-25 18:34:25 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-02-25 18:34:25 -0800 |
commit | 45d35d5739d05e602bc317739485693e0e9ff0b5 (patch) | |
tree | 61801368d96662baff145d3271fd887ca104391c /rt/t | |
parent | 662be3ece2ef8c7f05fcbfaa699d80a6a73ca110 (diff) |
RT 4.0.19
Diffstat (limited to 'rt/t')
30 files changed, 299 insertions, 140 deletions
diff --git a/rt/t/api/action-createtickets.t b/rt/t/api/action-createtickets.t index c37e2ed12..ceed4231c 100644 --- a/rt/t/api/action-createtickets.t +++ b/rt/t/api/action-createtickets.t @@ -105,7 +105,7 @@ is ($dependson->FirstCustomFieldValue('GlobalCF'), 'A Value', 'global custom field was set'); is ($dependson->FirstCustomFieldValue('QueueCF'), 'Another Value', 'queue custom field was set'); -unlike ($dependson->Subject, qr/{/, "The subject doesn't have braces in it. that means we're interpreting expressions"); +unlike ($dependson->Subject, qr/\{/, "The subject doesn't have braces in it. that means we're interpreting expressions"); is ($t->ReferredToBy->Count,1, "It's only referred to by one other ticket"); is ($t->ReferredToBy->First->BaseObj->Id,$t->DependsOn->First->TargetObj->Id, "The same ticket that depends on it refers to it."); use RT::Action::CreateTickets; diff --git a/rt/t/api/date.t b/rt/t/api/date.t index 728a4a2bc..cc1c694cc 100644 --- a/rt/t/api/date.t +++ b/rt/t/api/date.t @@ -94,7 +94,7 @@ my $current_user; '1970-01-01T00:00:00Z', "W3CDTF format with defaults"); is($date->Get(Format =>'RFC2822'), - 'Thu, 1 Jan 1970 00:00:00 +0000', + 'Thu, 01 Jan 1970 00:00:00 +0000', "RFC2822 format with defaults"); is($date->Get(Format =>'LocalizedDateTime'), 'Thu, Jan 1, 1970 12:00:00 AM', @@ -107,7 +107,7 @@ my $current_user; '1970-01-01', "W3CDTF format without time part"); is($date->RFC2822(Time => 0), - 'Thu, 1 Jan 1970', + 'Thu, 01 Jan 1970', "RFC2822 format without time part"); is($date->LocalizedDateTime(Time => 0), 'Thu, Jan 1, 1970', @@ -137,7 +137,7 @@ my $current_user; "RFC2822 format without date part and seconds"); is($date->RFC2822(DayOfWeek => 0), - '1 Jan 1970 00:00:00 +0000', + '01 Jan 1970 00:00:00 +0000', "RFC2822 format without 'day of week' part"); is($date->RFC2822(DayOfWeek => 0, Date => 0), '00:00:00 +0000', @@ -163,7 +163,7 @@ my $current_user; '1970-01-01', "'Date' method, W3CDTF format"); is($date->Date(Format => 'RFC2822'), - 'Thu, 1 Jan 1970', + 'Thu, 01 Jan 1970', "'Date' method, RFC2822 format"); is($date->Date(Time => 1), '1970-01-01', @@ -195,7 +195,7 @@ my $current_user; '1970-01-01T00:00:00Z', "'DateTime' method, W3CDTF format"); is($date->DateTime(Format =>'RFC2822'), - 'Thu, 1 Jan 1970 00:00:00 +0000', + 'Thu, 01 Jan 1970 00:00:00 +0000', "'DateTime' method, RFC2822 format"); is($date->DateTime(Date => 0, Time => 0), '1970-01-01 00:00:00', @@ -209,14 +209,14 @@ my $current_user; $date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-01-01 15:10:00' ); is($date->ISO( Timezone => 'user' ), '2005-01-01 18:10:00', "ISO"); is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T18:10:00+03:00', "W3C DTF"); - is($date->RFC2822( Timezone => 'user' ), 'Sat, 1 Jan 2005 18:10:00 +0300', "RFC2822"); + is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 18:10:00 +0300', "RFC2822"); # DST $date = RT::Date->new( $current_user ); $date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-07-01 15:10:00' ); is($date->ISO( Timezone => 'user' ), '2005-07-01 19:10:00', "ISO"); is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T19:10:00+04:00', "W3C DTF"); - is($date->RFC2822( Timezone => 'user' ), 'Fri, 1 Jul 2005 19:10:00 +0400', "RFC2822"); + is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 19:10:00 +0400', "RFC2822"); } { # negative timezone @@ -225,14 +225,14 @@ my $current_user; $date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-01-01 15:10:00' ); is($date->ISO( Timezone => 'user' ), '2005-01-01 10:10:00', "ISO"); is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T10:10:00-05:00', "W3C DTF"); - is($date->RFC2822( Timezone => 'user' ), 'Sat, 1 Jan 2005 10:10:00 -0500', "RFC2822"); + is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 10:10:00 -0500', "RFC2822"); # DST $date = RT::Date->new( $current_user ); $date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-07-01 15:10:00' ); is($date->ISO( Timezone => 'user' ), '2005-07-01 11:10:00', "ISO"); is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T11:10:00-04:00', "W3C DTF"); - is($date->RFC2822( Timezone => 'user' ), 'Fri, 1 Jul 2005 11:10:00 -0400', "RFC2822"); + is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 11:10:00 -0400', "RFC2822"); } warning_like @@ -306,8 +306,6 @@ my $year = (localtime(time))[5] + 1900; { # set+datemanip format(Time::ParseDate) my $date = RT::Date->new(RT->SystemUser); - $date->Set(Format => 'unknown', Value => 'weird date'); - is($date->Unix, 0, "date was wrong"); RT->Config->Set( Timezone => 'Europe/Moscow' ); $date->Set(Format => 'datemanip', Value => '2005-11-28 15:10:00'); @@ -325,7 +323,9 @@ my $year = (localtime(time))[5] + 1900; { # set+unknown format(Time::ParseDate) my $date = RT::Date->new(RT->SystemUser); - $date->Set(Format => 'unknown', Value => 'weird date'); + warnings_like { + $date->Set(Format => 'unknown', Value => 'weird date'); + } qr{Couldn't parse date 'weird date' by Time::ParseDate}; is($date->Unix, 0, "date was wrong"); RT->Config->Set( Timezone => 'Europe/Moscow' ); @@ -456,12 +456,12 @@ my $year = (localtime(time))[5] + 1900; RT->Config->Set( DateTimeFormat => 'RFC2822' ); $date->Unix(1); - is($date->AsString, 'Thu, 1 Jan 1970 00:00:01 +0000', "correct string"); + is($date->AsString, 'Thu, 01 Jan 1970 00:00:01 +0000', "correct string"); RT->Config->Set( DateTimeFormat => { Format => 'RFC2822', Seconds => 0 } ); $date->Unix(1); - is($date->AsString, 'Thu, 1 Jan 1970 00:00 +0000', "correct string"); - is($date->AsString(Seconds => 1), 'Thu, 1 Jan 1970 00:00:01 +0000', "correct string"); + is($date->AsString, 'Thu, 01 Jan 1970 00:00 +0000', "correct string"); + is($date->AsString(Seconds => 1), 'Thu, 01 Jan 1970 00:00:01 +0000', "correct string"); } { # DurationAsString diff --git a/rt/t/api/group.t b/rt/t/api/group.t index 2c1ca73cf..d55fc5c4a 100644 --- a/rt/t/api/group.t +++ b/rt/t/api/group.t @@ -20,11 +20,19 @@ ok($ng->LoadUserDefinedGroup('TestGroup'), "Loaded testgroup"); is($ng->id , $group->id, "Loaded the right group"); -ok (($id,$msg) = $ng->AddMember('1'), "Added a member to the group"); +my @users = (undef); +for my $number (1..3) { + my $user = RT::User->new(RT->SystemUser); + $user->Create( Name => "User $number" ); + push @users, $user->id; +} + + +ok (($id,$msg) = $ng->AddMember( $users[1] ), "Added a member to the group"); ok($id, $msg); -ok (($id,$msg) = $ng->AddMember('2' ), "Added a member to the group"); +ok (($id,$msg) = $ng->AddMember( $users[2] ), "Added a member to the group"); ok($id, $msg); -ok (($id,$msg) = $ng->AddMember('3' ), "Added a member to the group"); +ok (($id,$msg) = $ng->AddMember( $users[3] ), "Added a member to the group"); ok($id, $msg); # Group 1 now has members 1, 2 ,3 @@ -34,7 +42,7 @@ ok (my ($id_2, $msg_2) = $group_2->CreateUserDefinedGroup( Name => 'TestGroup2', isnt ($id_2 , 0, "Created group 2 ok- $msg_2 "); ok (($id,$msg) = $group_2->AddMember($ng->PrincipalId), "Made TestGroup a member of testgroup2"); ok($id, $msg); -ok (($id,$msg) = $group_2->AddMember('1' ), "Added member RT_System to the group TestGroup2"); +ok (($id,$msg) = $group_2->AddMember( $users[1] ), "Added member User 1 to the group TestGroup2"); ok($id, $msg); # Group 2 how has 1, g1->{1, 2,3} @@ -48,12 +56,12 @@ ok($id, $msg); # g3 now has g2->{1, g1->{1,2,3}} my $principal_1 = RT::Principal->new(RT->SystemUser); -$principal_1->Load('1'); +$principal_1->Load( $users[1] ); my $principal_2 = RT::Principal->new(RT->SystemUser); -$principal_2->Load('2'); +$principal_2->Load( $users[2] ); -ok (($id,$msg) = $group_3->AddMember('1' ), "Added member RT_System to the group TestGroup2"); +ok (($id,$msg) = $group_3->AddMember( $users[1] ), "Added member User 1 to the group TestGroup2"); ok($id, $msg); # g3 now has 1, g2->{1, g1->{1,2,3}} diff --git a/rt/t/api/rights.t b/rt/t/api/rights.t index 107fb2b35..5cf3a0008 100644 --- a/rt/t/api/rights.t +++ b/rt/t/api/rights.t @@ -1,17 +1,14 @@ -use RT::Test nodata => 1, tests => 30; +use RT::Test nodata => 1, tests => 38; use strict; use warnings; +use Test::Warn; + +sub reset_rights { RT::Test->set_rights } + # clear all global right -{ - my $acl = RT::ACL->new(RT->SystemUser); - $acl->Limit( FIELD => 'RightName', OPERATOR => '!=', VALUE => 'SuperUser' ); - $acl->LimitToObject( $RT::System ); - while( my $ace = $acl->Next ) { - $ace->Delete; - } -} +reset_rights; my $queue = RT::Test->load_or_create_queue( Name => 'Regression' ); ok $queue && $queue->id, 'loaded or created queue'; @@ -146,3 +143,38 @@ my $ticket2; "user is not AdminCc and can't modify ticket2 (same question different answer)" ); } + +my $queue2 = RT::Test->load_or_create_queue( Name => 'Rights' ); +ok $queue2 && $queue2->id, 'loaded or created queue'; + +my $user2 = RT::Test->load_or_create_user( + Name => 'user2', Password => 'password', +); +ok $user2 && $user2->id, 'Created user: ' . $user2->Name . ' with id ' . $user2->Id; + +warning_like { + ok( !$user2->HasRight( Right => 'Foo', Object => $queue2 ), + "HasRight false for invalid right Foo" + ); +} qr/Invalid right\. Couldn't canonicalize right 'Foo'/, + 'Got warning on invalid right'; + + +note "Right name canonicalization"; +{ + reset_rights; + my ($ok, $msg) = $user->PrincipalObj->GrantRight( + Right => "showticket", + Object => RT->System, + ); + ok $ok, "Granted showticket: $msg"; + ok $user->HasRight( Right => "ShowTicket", Object => RT->System ), "HasRight ShowTicket"; + + reset_rights; + ($ok, $msg) = $user->PrincipalObj->GrantRight( + Right => "ShowTicket", + Object => RT->System, + ); + ok $ok, "Granted ShowTicket: $msg"; + ok $user->HasRight( Right => "showticket", Object => RT->System ), "HasRight showticket"; +} diff --git a/rt/t/api/rights_show_ticket.t b/rt/t/api/rights_show_ticket.t index c8107fe07..b7bec70de 100644 --- a/rt/t/api/rights_show_ticket.t +++ b/rt/t/api/rights_show_ticket.t @@ -207,7 +207,6 @@ diag "Testing with UseSQLForACLChecks => $option"; } sub have_no_rights { - $SIG{'INT'} = $SIG{'TERM'} = sub { print STDERR Carp::longmess('boo'); exit 1 }; local $Test::Builder::Level = $Test::Builder::Level + 1; foreach my $u ( @_ ) { foreach my $q ( diff --git a/rt/t/api/searchbuilder.t b/rt/t/api/searchbuilder.t index 8562bfc2b..84568718d 100644 --- a/rt/t/api/searchbuilder.t +++ b/rt/t/api/searchbuilder.t @@ -2,7 +2,7 @@ use strict; use warnings; use RT; -use RT::Test tests => 11; +use RT::Test tests => 19; { @@ -37,3 +37,27 @@ is_deeply(\@items_ids, \@sorted_ids, "ItemsArrayRef sorts alphabetically by name } +#20767: CleanSlate doesn't clear RT::SearchBuilder's flags for handling Disabled columns +{ + my $items; + + ok(my $queues = RT::Queues->new(RT->SystemUser), 'Created a queues object'); + ok( $queues->UnLimit(),'Unlimited the result set of the queues object'); + + # sanity check + is( $queues->{'handled_disabled_column'} => undef, 'handled_disabled_column IS NOT set' ); + is( $queues->{'find_disabled_rows'} => undef, 'find_disabled_rows IS NOT set ' ); + + $queues->LimitToDeleted; + + # sanity check + ok( $queues->{'handled_disabled_column'}, 'handled_disabled_column IS set' ); + ok( $queues->{'find_disabled_rows'}, 'find_disabled_rows IS set ' ); + + $queues->CleanSlate; + + # these fail without the overloaded CleanSlate method + is( $queues->{'handled_disabled_column'} => undef, 'handled_disabled_column IS NOT set' ); + is( $queues->{'find_disabled_rows'} => undef, 'find_disabled_rows IS NOT set ' ); +} + diff --git a/rt/t/fts/indexed_mysql.t b/rt/t/fts/indexed_mysql.t index c124ff8f8..a54382ff8 100644 --- a/rt/t/fts/indexed_mysql.t +++ b/rt/t/fts/indexed_mysql.t @@ -41,7 +41,7 @@ sub setup_indexing { mkdir $tmp; my $sphinx_conf = $output; - $sphinx_conf =~ s/.*?source rt {/source rt {/ms; + $sphinx_conf =~ s/.*?source rt \{/source rt {/ms; $sphinx_conf =~ s{\Q$RT::VarPath\E/sphinx/}{$tmp/}g; $sphinx{'config'} = File::Spec->catfile( $tmp, 'sphinx.conf' ); diff --git a/rt/t/fts/indexed_oracle.t b/rt/t/fts/indexed_oracle.t index 98db30439..a5b15bd82 100644 --- a/rt/t/fts/indexed_oracle.t +++ b/rt/t/fts/indexed_oracle.t @@ -6,7 +6,7 @@ use RT::Test tests => undef; plan skip_all => 'Not Oracle' unless RT->Config->Get('DatabaseType') eq 'Oracle'; plan tests => 13; -RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 1 ); +RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 1, IndexName => 'rt_fts_index' ); setup_indexing(); diff --git a/rt/t/mail/dashboards.t b/rt/t/mail/dashboards.t index edd455300..6bf4ba520 100644 --- a/rt/t/mail/dashboards.t +++ b/rt/t/mail/dashboards.t @@ -1,7 +1,7 @@ use strict; use warnings; -use RT::Test tests => 181; +use RT::Test tests => undef; use Test::Warn; use RT::Dashboard::Mailer; @@ -102,15 +102,13 @@ sub produces_dashboard_mail_ok { # {{{ my $mail = parse_mail( $mails[0] ); is($mail->head->get('Subject'), $subject); is($mail->head->get('From'), "root\n"); + is($mail->head->get('Content-Transfer-Encoding'), "base64\n"); is($mail->head->get('X-RT-Dashboard-Id'), "$dashboard_id\n"); is($mail->head->get('X-RT-Dashboard-Subscription-Id'), "$subscription_id\n"); - SKIP: { - skip 'Weird MIME failure', 2; - my $body = $mail->stringify_body; - like($body, qr{My dashboards}); - like($body, qr{<a href="http://[^/]+/Dashboards/\d+/Testing!">Testing!</a>}); - }; + my $body = $mail->bodyhandle->as_string; + like($body, qr{My dashboards}); + like($body, qr{<a href="http://[^/]+/Dashboards/\d+/Testing!">Testing!</a>}); } # }}} sub produces_no_dashboard_mail_ok { # {{{ @@ -202,12 +200,9 @@ is($mail->head->get('From'), "dashboard\@example.com\n"); is($mail->head->get('X-RT-Dashboard-Id'), "$dashboard_id\n"); is($mail->head->get('X-RT-Dashboard-Subscription-Id'), "$subscription_id\n"); -SKIP: { - skip 'Weird MIME failure', 2; - my $body = $mail->stringify_body; - unlike($body, qr{My dashboards}); - unlike($body, qr{Testing!}); -}; +my $body = $mail->bodyhandle->as_string; +unlike($body, qr{My dashboards}); +unlike($body, qr{Testing!}); delete_dashboard($dashboard_id); @@ -368,3 +363,4 @@ produces_no_dashboard_mail_ok( Time => $bad_time, ); +done_testing; diff --git a/rt/t/mail/digest-attributes.t b/rt/t/mail/digest-attributes.t index badd59b87..54c1c803f 100644 --- a/rt/t/mail/digest-attributes.t +++ b/rt/t/mail/digest-attributes.t @@ -136,14 +136,14 @@ is( $c_susp, 1, "correct number of suspended messages" ); # the first time get the content email_digest_like( '--mode daily --print', qr/in the last day/ ); # The second time run it for real so we make sure that we get RT to mark the txn as sent -email_digest_like( '--mode daily', qr/maildaily\@/ ); +email_digest_like( '--mode daily --verbose', qr/maildaily\@/ ); # now we should have nothing to do, so no content. email_digest_like( '--mode daily --print', '' ); # the first time get the content email_digest_like( '--mode weekly --print', qr/in the last seven days/ ); # The second time run it for real so we make sure that we get RT to mark the txn as sent -email_digest_like( '--mode weekly', qr/mailweekly\@/ ); +email_digest_like( '--mode weekly --verbose', qr/mailweekly\@/ ); # now we should have nothing to do, so no content. email_digest_like( '--mode weekly --print', '' ); diff --git a/rt/t/mail/disposition-outgoing.t b/rt/t/mail/disposition-outgoing.t index 06295a09c..cbfe43b74 100644 --- a/rt/t/mail/disposition-outgoing.t +++ b/rt/t/mail/disposition-outgoing.t @@ -50,7 +50,7 @@ a fake patch $mail =~ s/^Content-disposition: .+?\n(?=\n)//ism; my $rt = send_and_receive($mail); - like $rt, qr/Content-Disposition:\s*inline.+?filename\.patch/is, 'found default (inline) disposition'; + like $rt, qr/Content-Disposition:\s*attachment.+?filename\.patch/is, 'found default (attachment) disposition'; } sub send_and_receive { diff --git a/rt/t/mail/gnupg-reverification.t b/rt/t/mail/gnupg-reverification.t index 939bf3333..deef1ec24 100644 --- a/rt/t/mail/gnupg-reverification.t +++ b/rt/t/mail/gnupg-reverification.t @@ -1,7 +1,7 @@ use strict; use warnings; -use RT::Test::GnuPG tests => 216, gnupg_options => { passphrase => 'rt-test' }; +use RT::Test::GnuPG tests => 232, gnupg_options => { passphrase => 'rt-test' }; diag "load Everyone group"; my $everyone; @@ -62,10 +62,12 @@ foreach my $file ( @files ) { $m->content_like(qr/This is .*ID:$eid/ims, "$eid: content is there and message is decrypted"); $m->next_warning_like(qr/public key not found/); + $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); # some mails contain multiple signatures if ($eid == 5 || $eid == 17 || $eid == 18) { $m->next_warning_like(qr/public key not found/); + $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); } $m->no_leftover_warnings_ok; diff --git a/rt/t/mail/mime_decoding.t b/rt/t/mail/mime_decoding.t index 4b3e3c075..fbf884932 100644 --- a/rt/t/mail/mime_decoding.t +++ b/rt/t/mail/mime_decoding.t @@ -1,6 +1,6 @@ use strict; use warnings; -use RT::Test nodb => 1, tests => 13; +use RT::Test nodb => 1, tests => 14; use_ok('RT::I18N'); @@ -34,6 +34,16 @@ diag q{'=' char in a trailing part after an encoded part}; ); } +diag q{adding quotes around mime words containing specials when word is already quoted}; +{ + my $str = <<"END"; +Content-Disposition: attachment; filename="=?iso-8859-1?Q?foobar,_?= + =?iso-8859-1?Q?barfoo.docx?=" +END + my $decoded = 'Content-Disposition: attachment; filename="foobar, barfoo.docx"'; + is( RT::I18N::DecodeMIMEWordsToUTF8($str), $decoded, "No added quotes" ); +} + diag q{regression test for #5248 from rt3.fsck.com}; { my $str = qq{Subject: =?ISO-8859-1?Q?Re=3A_=5BXXXXXX=23269=5D_=5BComment=5D_Frag?=} diff --git a/rt/t/shredder/utils.pl b/rt/t/shredder/utils.pl index 7be951370..a3d0cf59a 100644 --- a/rt/t/shredder/utils.pl +++ b/rt/t/shredder/utils.pl @@ -8,8 +8,14 @@ require RT::Test; BEGIN { ### after: push @INC, qw(@RT_LIB_PATH@); + + use RT; + RT->LoadConfig; + RT->InitPluginPaths; + RT->InitClasses; } -use RT::Shredder; + +require RT::Shredder; =head1 DESCRIPTION @@ -282,8 +288,7 @@ sub dump_sqlite my $old_fhkn = $dbh->{'FetchHashKeyName'}; $dbh->{'FetchHashKeyName'} = 'NAME_lc'; - my $sth = $dbh->table_info( '', '%', '%', 'TABLE' ) || die $DBI::err; - my @tables = keys %{$sth->fetchall_hashref( 'table_name' )}; + my @tables = $RT::Handle->_TableNames( $dbh ); my $res = {}; foreach my $t( @tables ) { diff --git a/rt/t/ticket/search_by_links.t b/rt/t/ticket/search_by_links.t index d25d3002e..265771846 100644 --- a/rt/t/ticket/search_by_links.t +++ b/rt/t/ticket/search_by_links.t @@ -2,7 +2,7 @@ use strict; use warnings; -use RT::Test nodata => 1, tests => 98; +use RT::Test nodata => 1, tests => 100; use RT::Ticket; my $q = RT::Test->load_or_create_queue( Name => 'Regression' ); @@ -71,6 +71,14 @@ $total += @tickets; } run_tests(); +# make sure search by id is on LocalXXX columns +{ + my $tickets = RT::Tickets->new( RT->SystemUser ); + $tickets->FromSQL('MemberOf = '. $tickets[0]->id); + like $tickets->BuildSelectQuery, qr/LocalBase/; + like $tickets->BuildSelectQuery, qr/LocalTarget/; +} + # another set with tests of combinations searches @tickets = RT::Test->create_tickets( { Queue => $q->id }, diff --git a/rt/t/ticket/search_by_watcher.t b/rt/t/ticket/search_by_watcher.t index a6800bbb4..4fbc2617b 100644 --- a/rt/t/ticket/search_by_watcher.t +++ b/rt/t/ticket/search_by_watcher.t @@ -2,7 +2,7 @@ use strict; use warnings; -use RT::Test nodata => 1, tests => 2108; +use RT::Test nodata => 1, tests => undef; use RT::Ticket; my $q = RT::Test->load_or_create_queue( Name => 'Regression' ); @@ -101,40 +101,41 @@ sub run_auto_tests { run_test( $query, %checks ); } } } -# XXX: It -# @queries = ( -# '? AND ? AND ?' => sub { $_[0] and $_[1] and $_[2] }, -# '(? OR ?) AND ?' => sub { return (($_[0] or $_[1]) and $_[2]) }, -# '? OR (? AND ?)' => sub { $_[0] or ($_[1] and $_[2]) }, -# '(? AND ?) OR ?' => sub { ($_[0] and $_[1]) or $_[2] }, -# '? AND (? OR ?)' => sub { $_[0] and ($_[1] or $_[2]) }, -# '? OR ? OR ?' => sub { $_[0] or $_[1] or $_[2] }, -# ); -# while ( my ($template, $t_cb) = splice @queries, 0, 2 ) { -# my @atmp = @conditions; -# while ( my ($a, $a_cb) = splice @atmp, 0, 2 ) { -# my @btmp = @conditions; -# while ( my ($b, $b_cb) = splice @btmp, 0, 2 ) { -# next if $a eq $b; -# my @ctmp = @conditions; -# while ( my ($c, $c_cb) = splice @ctmp, 0, 2 ) { -# next if $a eq $c; -# next if $b eq $c; -# -# my %checks = (); -# foreach my $ticket ( @tickets ) { -# my $s = $ticket->Subject; -# $checks{ $s } = $t_cb->( scalar $a_cb->($s), scalar $b_cb->($s), scalar $c_cb->($s) ); -# } -# -# my $query = $template; -# foreach my $tmp ($a, $b, $c) { -# $query =~ s/\?/$tmp/; -# } -# -# run_test( $query, %checks ); -# } } } -# } + return unless $ENV{'RT_TEST_HEAVY'}; + + @queries = ( + '? AND ? AND ?' => sub { $_[0] and $_[1] and $_[2] }, + '(? OR ?) AND ?' => sub { return (($_[0] or $_[1]) and $_[2]) }, + '? OR (? AND ?)' => sub { $_[0] or ($_[1] and $_[2]) }, + '(? AND ?) OR ?' => sub { ($_[0] and $_[1]) or $_[2] }, + '? AND (? OR ?)' => sub { $_[0] and ($_[1] or $_[2]) }, + '? OR ? OR ?' => sub { $_[0] or $_[1] or $_[2] }, + ); + while ( my ($template, $t_cb) = splice @queries, 0, 2 ) { + my @atmp = @conditions; + while ( my ($a, $a_cb) = splice @atmp, 0, 2 ) { + my @btmp = @conditions; + while ( my ($b, $b_cb) = splice @btmp, 0, 2 ) { + next if $a eq $b; + my @ctmp = @conditions; + while ( my ($c, $c_cb) = splice @ctmp, 0, 2 ) { + next if $a eq $c; + next if $b eq $c; + + my %checks = (); + foreach my $ticket ( @tickets ) { + my $s = $ticket->Subject; + $checks{ $s } = $t_cb->( scalar $a_cb->($s), scalar $b_cb->($s), scalar $c_cb->($s) ); + } + + my $query = $template; + foreach my $tmp ($a, $b, $c) { + $query =~ s/\?/$tmp/; + } + + run_test( $query, %checks ); + } } } + } } @@ -266,4 +267,4 @@ my $nobody = RT::Nobody(); } @tickets = (); - +done_testing(); diff --git a/rt/t/web/articles-links.t b/rt/t/web/articles-links.t index 713dc05e4..eb6de51b3 100644 --- a/rt/t/web/articles-links.t +++ b/rt/t/web/articles-links.t @@ -37,7 +37,7 @@ $m->content_contains('instance of ticket #17421', 'got the name of the article i # delete RT::Article's Name method on the server so we'll need to AUTOLOAD it my $clone = $m->clone; $clone->get_ok('/delete-article-name-method.html'); -like($clone->content, qr/{deleted}/); +like($clone->content, qr/\{deleted\}/); $m->form_name('TicketUpdate'); $m->click('SubmitTicket'); diff --git a/rt/t/web/case-sensitivity.t b/rt/t/web/case-sensitivity.t index f9c61b519..5f40ef690 100644 --- a/rt/t/web/case-sensitivity.t +++ b/rt/t/web/case-sensitivity.t @@ -22,7 +22,7 @@ $m->login; require JSON; is_deeply( JSON::from_json( $m->content ), - [{"value" => "root\@localhost","label" => "Enoch Root"}] + [{"value" => "root\@localhost","label" => "Enoch Root", id=>$root_id}] ); } diff --git a/rt/t/web/cf_date.t b/rt/t/web/cf_date.t index 4ea93e4de..e69833c13 100644 --- a/rt/t/web/cf_date.t +++ b/rt/t/web/cf_date.t @@ -2,7 +2,7 @@ use strict; use warnings; -use RT::Test tests => 35; +use RT::Test tests => undef; my ( $baseurl, $m ) = RT::Test->started_ok; ok $m->login, 'logged in as root'; @@ -183,4 +183,10 @@ diag 'check invalid inputs'; $m->content_contains('test cf date:', 'has no cf date field on the page' ); $m->content_lacks('foodate', 'invalid dates not set' ); + + my @warnings = $m->get_warnings; + chomp @warnings; + is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} ); } + +done_testing; diff --git a/rt/t/web/cf_datetime.t b/rt/t/web/cf_datetime.t index 8cc099d1c..4580c4a4f 100644 --- a/rt/t/web/cf_datetime.t +++ b/rt/t/web/cf_datetime.t @@ -2,7 +2,7 @@ use strict; use warnings; -use RT::Test tests => 51; +use RT::Test tests => undef; RT->Config->Set( 'Timezone' => 'EST5EDT' ); # -04:00 my ($baseurl, $m) = RT::Test->started_ok; @@ -209,6 +209,10 @@ diag 'check invalid inputs'; $m->content_contains('test cf datetime:', 'has cf datetime field on the page'); $m->content_lacks('foodate', 'invalid dates not set'); + + my @warnings = $m->get_warnings; + chomp @warnings; + is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} ); } sub is_results_number { @@ -232,3 +236,4 @@ sub is_results_number { # to make $m->DESTROY happy undef $m; +done_testing; diff --git a/rt/t/web/charting.t b/rt/t/web/charting.t index 32d95d99b..e19ec41ae 100644 --- a/rt/t/web/charting.t +++ b/rt/t/web/charting.t @@ -76,3 +76,20 @@ $m->content_like(qr{<img src="/Search/Chart\?}, "Found image"); $m->get_ok( "/Search/Chart?Query=id>0&PrimaryGroupBy=Requestor.Phone" ); is( $m->content_type, "image/png" ); ok( length($m->content), "Has content" ); + +diag "Confirm subnav links use Query param before saved search in session."; + +$m->get_ok( "/Search/Chart.html?Query=id>0" ); +my $advanced = $m->find_link( text => 'Advanced' )->URI->equery; +like( $advanced, qr{Query=id%3E0}, + 'Advanced link has Query param with id search' + ); + +# Load the session with another search. +$m->get_ok( "/Search/Results.html?Query=Queue='General'" ); + +$m->get_ok( "/Search/Chart.html?Query=id>0" ); +$advanced = $m->find_link( text => 'Advanced' )->URI->equery; +like( $advanced, qr{Query=id%3E0}, + 'Advanced link still has Query param with id search' + ); diff --git a/rt/t/web/command_line.t b/rt/t/web/command_line.t index 7c444f49d..a5c52d261 100644 --- a/rt/t/web/command_line.t +++ b/rt/t/web/command_line.t @@ -164,106 +164,106 @@ expect_like(qr/Queue: EditedQueue$$/, 'Verified lack of change'); # Test reading and setting custom fields without spaces expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking initial value'); -expect_like(qr/CF\.{myCF$$}:/i, 'Verified initial empty value (CF-x syntax)'); +expect_like(qr/\QCF.{myCF$$}\E:/i, 'Verified initial empty value (CF-x syntax)'); expect_send("show ticket/$ticket_id -f CF.{myCF$$}", 'Checking initial value'); -expect_like(qr/CF\.{myCF$$}:/i, 'Verified initial empty value (CF.{x} syntax)'); +expect_like(qr/\QCF.{myCF$$}\E:/i, 'Verified initial empty value (CF.{x} syntax)'); expect_send("edit ticket/$ticket_id set 'CF-myCF$$=VALUE' ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value'); -expect_like(qr/CF\.{myCF$$}: VALUE/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E: VALUE/i, 'Verified change'); # Test setting 0 as value of the custom field expect_send("edit ticket/$ticket_id set 'CF-myCF$$=0' ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value'); -expect_like(qr/CF\.{myCF$$}: 0/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E: 0/i, 'Verified change'); expect_send("edit ticket/$ticket_id set 'CF.{myCF$$}=VALUE' ",'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f CF.{myCF$$}", 'Checking new value'); -expect_like(qr/CF\.{myCF$$}: VALUE/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E: VALUE/i, 'Verified change'); # Test setting 0 as value of the custom field expect_send("edit ticket/$ticket_id set 'CF.{myCF$$}=0' ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f CF.{myCF$$}", 'Checking new value'); -expect_like(qr/CF\.{myCF$$}: 0/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E: 0/i, 'Verified change'); # Test reading and setting custom fields with spaces expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking initial value'); -expect_like(qr/CF\.{my CF$$}:/i, 'Verified change'); +expect_like(qr/\QCF.{my CF$$}\E:/i, 'Verified change'); expect_send("edit ticket/$ticket_id set 'CF-my CF$$=VALUE' ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking new value'); -expect_like(qr/CF\.{my CF$$}: VALUE/i, 'Verified change'); +expect_like(qr/\QCF.{my CF$$}\E: VALUE/i, 'Verified change'); expect_send("ls -l 'id = $ticket_id' -f 'CF-my CF$$'", 'Checking new value'); -expect_like(qr/CF\.{my CF$$}: VALUE/i, 'Verified change'); +expect_like(qr/\QCF.{my CF$$}\E: VALUE/i, 'Verified change'); expect_send("show ticket/$ticket_id -f 'CF.{my CF$$}'", 'Checking initial value'); -expect_like(qr/CF\.{my CF$$}: VALUE/i, 'Verified change'); +expect_like(qr/\QCF.{my CF$$}\E: VALUE/i, 'Verified change'); expect_send("edit ticket/$ticket_id set 'CF.{my CF$$}=NEW' ", 'Changing CF...'); expect_send("show ticket/$ticket_id -f 'CF.{my CF$$}'", 'Checking new value'); -expect_like(qr/CF\.{my CF$$}: NEW/i, 'Verified change'); +expect_like(qr/\QCF.{my CF$$}\E: NEW/i, 'Verified change'); expect_send("ls -l 'id = $ticket_id' -f 'CF.{my CF$$}'", 'Checking new value'); -expect_like(qr/CF\.{my CF$$}: NEW/i, 'Verified change'); +expect_like(qr/\QCF.{my CF$$}\E: NEW/i, 'Verified change'); # Test reading and setting single value custom field with commas or quotes expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking initial value'); -expect_like(qr/CF\.{myCF$$}:/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E:/i, 'Verified change'); expect_send("edit ticket/$ticket_id set CF-myCF$$=1,2,3", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value'); -expect_like(qr/CF\.{myCF$$}: 1,2,3/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E: 1,2,3/i, 'Verified change'); expect_send("edit ticket/$ticket_id set CF-myCF$$=\"1's,2,3\"", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value'); -expect_like(qr/CF\.{myCF$$}: 1's,2,3/i, 'Verified change'); +expect_like(qr/\QCF.{myCF$$}\E: 1's,2,3/i, 'Verified change'); # Test reading and setting custom fields with multiple values expect_send("show ticket/$ticket_id -f CF-MultipleCF$$", 'Checking initial value'); -expect_like(qr/CF\.{MultipleCF$$}:/i, 'Verified multiple cf change'); +expect_like(qr/\QCF.{MultipleCF$$}\E:/i, 'Verified multiple cf change'); expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=1,2,3 ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: 1,\s*2,\s*3/i, 'Verified multiple cf change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: 1,\s*2,\s*3/i, 'Verified multiple cf change'); expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=a,b,c ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: a,\s*b,\s*c/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: a,\s*b,\s*c/i, 'Verified change'); expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=a", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'del multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: b,\s*c/i, 'Verified multiple cf change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: b,\s*c/i, 'Verified multiple cf change'); expect_send("edit ticket/$ticket_id add CF.{MultipleCF$$}=o", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: b,\s*c,\s*o/i, 'Verified multiple cf change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: b,\s*c,\s*o/i, 'Verified multiple cf change'); expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"'a,b,c'\" ", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: 'a,b,c'/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: 'a,b,c'/i, 'Verified change'); expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=a", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: 'a,b,c'/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: 'a,b,c'/i, 'Verified change'); expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=q{a,b,c}", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: 'a,b,c'/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: 'a,b,c'/i, 'Verified change'); expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=a", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: 'a,b,c'/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: 'a,b,c'/i, 'Verified change'); expect_send("edit ticket/$ticket_id del CF.{MultipleCF$$}=\"'a,b,c'\"", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: \s*$/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: \s*$/i, 'Verified change'); expect_send("edit ticket/$ticket_id set CF.{MultipleCF$$}=\"q{1,2's,3}\"", 'Changing CF...'); expect_like(qr/Ticket $ticket_id updated/, 'Changed multiple cf'); expect_send("show ticket/$ticket_id -f CF.{MultipleCF$$}", 'Checking new value'); -expect_like(qr/CF\.{MultipleCF$$}: '1,2\\'s,3'/i, 'Verified change'); +expect_like(qr/\QCF.{MultipleCF$$}\E: '1,2\\'s,3'/i, 'Verified change'); # ... # change a ticket's ...[other properties]... diff --git a/rt/t/web/crypt-gnupg.t b/rt/t/web/crypt-gnupg.t index 1743a3a8e..85e090cbc 100644 --- a/rt/t/web/crypt-gnupg.t +++ b/rt/t/web/crypt-gnupg.t @@ -2,7 +2,7 @@ use strict; use warnings; use RT::Test::GnuPG - tests => 102, + tests => 104, gnupg_options => { passphrase => 'recipient', 'trust-model' => 'always', @@ -444,5 +444,7 @@ like($content, qr/KR-general\@example.com-K/, "KeyRequestors does not issue no-p like($content, qr/KR-nokey\@example.com \(no pubkey!\)-K/, "KeyRequestors DOES issue no-pubkey warning for nokey\@example.com"); $m->next_warning_like(qr/public key not found/); +$m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); $m->next_warning_like(qr/public key not found/); +$m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); $m->no_leftover_warnings_ok; diff --git a/rt/t/web/gnupg-select-keys-on-create.t b/rt/t/web/gnupg-select-keys-on-create.t index 893ae65c9..8c1ae448c 100644 --- a/rt/t/web/gnupg-select-keys-on-create.t +++ b/rt/t/web/gnupg-select-keys-on-create.t @@ -1,7 +1,7 @@ use strict; use warnings; -use RT::Test::GnuPG tests => 79, gnupg_options => { passphrase => 'rt-test' }; +use RT::Test::GnuPG tests => 83, gnupg_options => { passphrase => 'rt-test' }; use RT::Action::SendEmail; my $queue = RT::Test->load_or_create_queue( @@ -66,7 +66,11 @@ diag "check that things don't work if there is no key"; my @mail = RT::Test->fetch_caught_mails; ok !@mail, 'there are no outgoing emails'; - $m->next_warning_like(qr/public key not found/) for 1 .. 4; + for (1 .. 4) { + $m->next_warning_like(qr/public key not found/) ; + $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); + } + $m->no_leftover_warnings_ok; } diff --git a/rt/t/web/gnupg-select-keys-on-update.t b/rt/t/web/gnupg-select-keys-on-update.t index 1509d1df3..a5b01d3ae 100644 --- a/rt/t/web/gnupg-select-keys-on-update.t +++ b/rt/t/web/gnupg-select-keys-on-update.t @@ -1,7 +1,7 @@ use strict; use warnings; -use RT::Test::GnuPG tests => 86, gnupg_options => { passphrase => 'rt-test' }; +use RT::Test::GnuPG tests => 88, gnupg_options => { passphrase => 'rt-test' }; use RT::Action::SendEmail; @@ -82,7 +82,10 @@ diag "check that things don't work if there is no key"; my @mail = RT::Test->fetch_caught_mails; ok !@mail, 'there are no outgoing emails'; - $m->next_warning_like(qr/public key not found/) for 1 .. 2; + for (1 .. 2) { + $m->next_warning_like(qr/public key not found/); + $m->next_warning_like(qr/above error may result from an unconfigured RT\/GPG/); + } $m->no_leftover_warnings_ok; } diff --git a/rt/t/web/installer.t b/rt/t/web/installer.t index a34cdcb4b..79198a7e8 100644 --- a/rt/t/web/installer.t +++ b/rt/t/web/installer.t @@ -57,6 +57,7 @@ diag "Walking through install screens setting defaults"; $m->submit_form(with_fields => { DatabaseAdmin => $ENV{RT_DBA_USER}, DatabaseAdminPassword => $ENV{RT_DBA_PASSWORD}, + DatabasePassword => "rt_pass", }); } $m->content_contains('Connection succeeded'); diff --git a/rt/t/web/reminders.t b/rt/t/web/reminders.t index af7e2fb26..510235156 100644 --- a/rt/t/web/reminders.t +++ b/rt/t/web/reminders.t @@ -51,10 +51,10 @@ is($col->Count, 1, 'got a reminder'); my $reminder = $col->First; is($reminder->Subject, "baby's first reminder"); my $reminder_id = $reminder->id; -is($reminder->Status, 'new'); +is($reminder->Status, 'open'); -$ticket->SetStatus('new'); -is( $ticket->Status, 'new', 'changed back to new' ); +$ticket->SetStatus('open'); +is( $ticket->Status, 'open', 'changed back to new' ); $m->goto_ticket($ticket->id); $m->text_contains('New reminder:', "can create a new reminder"); @@ -72,7 +72,7 @@ DBIx::SearchBuilder::Record::Cachable->FlushCache; $reminder = RT::Ticket->new($user); $reminder->Load($reminder_id); is($reminder->Subject, 'changed the subject'); -is($reminder->Status, 'new'); +is($reminder->Status, 'open'); $m->goto_ticket($ticket->id); $m->form_name('UpdateReminders'); diff --git a/rt/t/web/rest_cfs_with_same_name.t b/rt/t/web/rest_cfs_with_same_name.t index 958f67177..9ab6e9a06 100644 --- a/rt/t/web/rest_cfs_with_same_name.t +++ b/rt/t/web/rest_cfs_with_same_name.t @@ -69,10 +69,10 @@ for my $queue_name (qw/foo bar/) { ] ); $text = $m->content; - like( $text, qr/^CF\.{test}: baz\s*$/m, 'cf value in rest show' ); + like( $text, qr/^CF\.\{test\}: baz\s*$/m, 'cf value in rest show' ); $text =~ s{.*}{}; # remove header - $text =~ s!CF\.{test}: baz!CF.{test}: newbaz!; + $text =~ s!CF\.\{test\}: baz!CF.{test}: newbaz!; $m->post( "$baseurl/REST/1.0/ticket/edit", [ diff --git a/rt/t/web/self_service.t b/rt/t/web/self_service.t index 49d9e37ee..adc90d776 100644 --- a/rt/t/web/self_service.t +++ b/rt/t/web/self_service.t @@ -1,13 +1,37 @@ use strict; use warnings; -use RT::Test tests => 9; + +use RT::Test + tests => 17, + config => 'Set( $ShowUnreadMessageNotifications, 1 );' +; my ($url, $m) = RT::Test->started_ok; -my ($ticket) = - RT::Test->create_ticket( Queue => 'General', Subject => 'test subject' ); +my $user_a = RT::Test->load_or_create_user( + Name => 'user_a', + Password => 'password', + EmailAddress => 'user_a@example.com', + Privileged => 0, +); +ok( $user_a && $user_a->id, 'loaded or created user' ); +ok( ! $user_a->Privileged, 'user is not privileged' ); + +# Load Cc group +my $Cc = RT::Group->new( RT->SystemUser ); +my($ok, $msg) = $Cc->LoadSystemRoleGroup( 'Cc' ); +ok($ok, $msg); +RT::Test->add_rights( { Principal => $Cc, Right => ['ShowTicket'] } ); + +my ($ticket) = RT::Test->create_ticket( + Queue => 'General', + Subject => 'test subject', + Cc => 'user_a@example.com', +); + +my @results = $ticket->Correspond( Content => 'sample correspondence' ); -$m->login(); +ok( $m->login('user_a' => 'password'), 'unprivileged user logged in' ); $m->get_ok( '/SelfService/Display.html?id=' . $ticket->id, 'got selfservice display page' ); @@ -16,4 +40,16 @@ my $title = '#' . $ticket->id . ': test subject'; $m->title_is( $title ); $m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" ); +# $ShowUnreadMessageNotifications tests: +$m->content_contains( "There are unread messages on this ticket." ); + +# mark the message as read +$m->follow_link_ok( + { text => 'jump to the first unread message and mark all messages as seen' }, + 'followed mark as seen link' +); + +$m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" ); +$m->content_lacks( "There are unread messages on this ticket." ); + # TODO need more SelfService tests diff --git a/rt/t/web/user_update.t b/rt/t/web/user_update.t index f55c773cd..c0e9e5264 100644 --- a/rt/t/web/user_update.t +++ b/rt/t/web/user_update.t @@ -35,7 +35,7 @@ $m->text_contains("Lang changed from 'en_us' to 'ja'"); $m->text_contains("実名", "Page content is japanese"); $m->submit_form_ok({ with_fields => { Lang => ''} }, "And set to the default"); -$m->text_contains("Langは「'ja'」から「''」に変更されました"); +$m->text_contains("Langは「'ja'」から「(値なし)」に変更されました"); $m->text_contains("Real Name", "Page content is english"); undef $m; |