summaryrefslogtreecommitdiff
path: root/rt/t
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-06-07 16:55:45 -0700
committerIvan Kohler <ivan@freeside.biz>2012-06-07 16:55:45 -0700
commitc24d6e2242ae0e026684b8f95decf156aba6e75e (patch)
tree8597d00e2e6bf2cf400437b9344f43b1500da412 /rt/t
parent6686c29104e555ea23446fe1db330664fa110bc0 (diff)
rt 4.0.6
Diffstat (limited to 'rt/t')
-rw-r--r--rt/t/api/date.t10
-rw-r--r--rt/t/api/tickets.t15
-rw-r--r--rt/t/lifecycles/basics.t2
-rw-r--r--rt/t/mail/mime_decoding.t28
-rw-r--r--rt/t/web/case-sensitivity.t2
-rw-r--r--rt/t/web/query_builder.t33
-rw-r--r--rt/t/web/redirect-after-login.t6
-rw-r--r--rt/t/web/rest.t83
-rw-r--r--rt/t/web/scrub.t4
-rw-r--r--rt/t/web/ticket_forward.t35
-rw-r--r--rt/t/web/ticket_links.t65
11 files changed, 264 insertions, 19 deletions
diff --git a/rt/t/api/date.t b/rt/t/api/date.t
index 9756e51c4..6fcaa494b 100644
--- a/rt/t/api/date.t
+++ b/rt/t/api/date.t
@@ -4,7 +4,7 @@ use Test::MockTime qw(set_fixed_time restore_time);
use DateTime;
use warnings; use strict;
-use RT::Test tests => 172;
+use RT::Test tests => 173;
use RT::User;
use Test::Warn;
@@ -85,9 +85,11 @@ my $current_user;
my $date = RT::Date->new(RT->SystemUser);
is($date->Unix, 0, "new date returns 0 in Unix format");
is($date->Get, '1970-01-01 00:00:00', "default is ISO format");
- is($date->Get(Format =>'SomeBadFormat'),
- '1970-01-01 00:00:00',
- "don't know format, return ISO format");
+ warning_like {
+ is($date->Get(Format =>'SomeBadFormat'),
+ '1970-01-01 00:00:00',
+ "don't know format, return ISO format");
+ } qr/Invalid date formatter/;
is($date->Get(Format =>'W3CDTF'),
'1970-01-01T00:00:00Z',
"W3CDTF format with defaults");
diff --git a/rt/t/api/tickets.t b/rt/t/api/tickets.t
index cabb00e50..50d08f756 100644
--- a/rt/t/api/tickets.t
+++ b/rt/t/api/tickets.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use RT;
-use RT::Test tests => 16;
+use RT::Test tests => 18;
{
@@ -101,3 +101,16 @@ ok( $unlimittickets->Count > 0, "UnLimited tickets object should return tickets"
}
+
+{
+ my $tickets = RT::Tickets->new( RT->SystemUser );
+ $tickets->Limit( FIELD => 'id', OPERATOR => '>', VALUE => 0 );
+ my $count = $tickets->Count();
+ ok $count > 1, "found more than one ticket";
+ undef $count;
+
+ $tickets->Limit( FIELD => 'id', OPERATOR => '=', VALUE => 1, ENTRYAGGREGATOR => 'none' );
+ $count = $tickets->Count();
+ ok $count == 1, "found one ticket";
+}
+
diff --git a/rt/t/lifecycles/basics.t b/rt/t/lifecycles/basics.t
index 40e239186..5825a105d 100644
--- a/rt/t/lifecycles/basics.t
+++ b/rt/t/lifecycles/basics.t
@@ -177,7 +177,7 @@ diag "deleted -> X via modify, only open is available";
my @form_values = $input->possible_values;
ok scalar @form_values, 'some options in the UI';
- is join('-', @form_values), '-open', 'only open and default available';
+ is join('-', @form_values), '-deleted-open', 'only default, current and open available';
}
diag "check illegal values and transitions";
diff --git a/rt/t/mail/mime_decoding.t b/rt/t/mail/mime_decoding.t
index b02f9795f..7515e2c41 100644
--- a/rt/t/mail/mime_decoding.t
+++ b/rt/t/mail/mime_decoding.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
-use RT::Test nodb => 1, tests => 8;
+use RT::Test nodb => 1, tests => 9;
use_ok('RT::I18N');
@@ -59,11 +59,29 @@ diag q{newline and encoded file name};
diag q{rfc2231};
{
my $str =
-"filename*=ISO-8859-1''%74%E9%73%74%2E%74%78%74 filename*=ISO-8859-1''%74%E9%73%74%2E%74%78%74";
+"attachment; filename*=ISO-8859-1''%74%E9%73%74%2E%74%78%74";
is(
- RT::I18N::DecodeMIMEWordsToEncoding( $str, 'utf-8' ),
- 'filename=tést.txt filename=tést.txt',
- 'right decodig'
+ RT::I18N::DecodeMIMEWordsToEncoding( $str, 'utf-8', 'Content-Disposition' ),
+ 'attachment; filename="tést.txt"',
+ 'right decoding'
+ );
+}
+
+diag q{rfc2231 param continuations};
+{
+ # XXX TODO: test various forms of the continuation stuff
+ # quotes around the values
+ my $hdr = <<'.';
+inline;
+ filename*0*=ISO-2022-JP'ja'%1b$B%3f7$7$$%25F%25%2d%259%25H%1b%28B;
+ filename*1*=%20;
+ filename*2*=%1b$B%25I%25%2d%25e%25a%25s%25H%1b%28B;
+ filename*3=.txt
+.
+ is(
+ RT::I18N::DecodeMIMEWordsToEncoding( $hdr, 'utf-8', 'Content-Disposition' ),
+ 'inline; filename="新しいテキスト ドキュメント.txt"',
+ 'decoded continuations as one string'
);
}
diff --git a/rt/t/web/case-sensitivity.t b/rt/t/web/case-sensitivity.t
index 276b7615a..f984bf3e4 100644
--- a/rt/t/web/case-sensitivity.t
+++ b/rt/t/web/case-sensitivity.t
@@ -75,7 +75,7 @@ my $cf;
# test custom field values auto completer
{
- $m->get_ok('/Helpers/Autocomplete/CustomFieldValues?term=eNo&Object---CustomField-'. $cf->id .'-Value');
+ $m->get_ok('/Helpers/Autocomplete/CustomFieldValues?term=eNo&Object---CustomField-'. $cf->id .'-Value&ContextId=1&ContextType=RT::Queue');
require JSON;
is_deeply(
JSON::from_json( $m->content ),
diff --git a/rt/t/web/query_builder.t b/rt/t/web/query_builder.t
index 0abbfaca8..5a64d4646 100644
--- a/rt/t/web/query_builder.t
+++ b/rt/t/web/query_builder.t
@@ -5,7 +5,7 @@ use HTTP::Request::Common;
use HTTP::Cookies;
use LWP;
use Encode;
-use RT::Test tests => 56;
+use RT::Test tests => 70;
my $cookie_jar = HTTP::Cookies->new;
my ($baseurl, $agent) = RT::Test->started_ok;
@@ -295,3 +295,34 @@ diag "click advanced, enter a valid SQL, but the field is lower cased";
);
}
+diag "make sure skipped order by field doesn't break search";
+{
+ my $t = RT::Test->create_ticket( Queue => 'General', Subject => 'test' );
+ ok $t && $t->id, 'created a ticket';
+
+ $agent->get_ok($url."Search/Edit.html");
+ ok($agent->form_name('BuildQueryAdvanced'), "found the form");
+ $agent->field("Query", "id = ". $t->id);
+ $agent->submit;
+
+ $agent->follow_link_ok({id => 'page-results'});
+ ok( $agent->find_link(
+ text => $t->id,
+ url_regex => qr{/Ticket/Display\.html},
+ ), "link to the ticket" );
+
+ $agent->follow_link_ok({id => 'page-edit_search'});
+ $agent->form_name('BuildQuery');
+ $agent->field("OrderBy", 'Requestor.EmailAddress', 3);
+ $agent->submit;
+ $agent->form_name('BuildQuery');
+ is $agent->value('OrderBy', 1), 'id';
+ is $agent->value('OrderBy', 2), '';
+ is $agent->value('OrderBy', 3), 'Requestor.EmailAddress';
+
+ $agent->follow_link_ok({id => 'page-results'});
+ ok( $agent->find_link(
+ text => $t->id,
+ url_regex => qr{/Ticket/Display\.html},
+ ), "link to the ticket" );
+}
diff --git a/rt/t/web/redirect-after-login.t b/rt/t/web/redirect-after-login.t
index d429d30d1..835b24c37 100644
--- a/rt/t/web/redirect-after-login.t
+++ b/rt/t/web/redirect-after-login.t
@@ -196,16 +196,17 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
# test REST login response
{
+ $agent = RT::Test::Web->new;
my $requested = $url."REST/1.0/?user=root;pass=password";
$agent->get($requested);
is($agent->status, 200, "Loaded a page");
is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST");
- $agent->get_ok($url);
- $agent->logout();
+ $agent->get_ok($url."REST/1.0");
}
# test REST login response for wrong pass
{
+ $agent = RT::Test::Web->new;
my $requested = $url."REST/1.0/?user=root;pass=passwrong";
$agent->get_ok($requested);
is($agent->status, 200, "Loaded a page");
@@ -217,6 +218,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) {
# test REST login response for no creds
{
+ $agent = RT::Test::Web->new;
my $requested = $url."REST/1.0/";
$agent->get_ok($requested);
is($agent->status, 200, "Loaded a page");
diff --git a/rt/t/web/rest.t b/rt/t/web/rest.t
index 5e7194c95..e38f201fb 100644
--- a/rt/t/web/rest.t
+++ b/rt/t/web/rest.t
@@ -1,7 +1,9 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use RT::Test tests => 18;
+use RT::Interface::REST;
+
+use RT::Test tests => 22;
my ($baseurl, $m) = RT::Test->started_ok;
@@ -69,3 +71,82 @@ for ("id: ticket/1",
$m->content_contains($_);
}
+# Create ticket 2 for testing ticket links
+for (2 .. 3) {
+ $m->post("$baseurl/REST/1.0/ticket/edit", [
+ user => 'root',
+ pass => 'password',
+ content => $text,
+ ], Content_Type => 'form-data');
+
+ $m->post(
+ "$baseurl/REST/1.0/ticket/1/links",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+ );
+
+ my $link_data = form_parse($m->content);
+
+ push @{$link_data->[0]->[1]}, 'DependsOn';
+ vpush($link_data->[0]->[2], 'DependsOn', $_);
+
+ $m->post(
+ "$baseurl/REST/1.0/ticket/1/links",
+ [
+ user => 'root',
+ pass => 'password',
+ content => form_compose($link_data),
+ ],
+ Content_Type => 'form-data',
+ );
+
+}
+
+# See what links get reported for ticket 1.
+$m->post(
+ "$baseurl/REST/1.0/ticket/1/links/show",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+);
+
+# Verify that the link was added correctly.
+my $content = form_parse($m->content);
+my $depends_on = vsplit($content->[0]->[2]->{DependsOn});
+@$depends_on = sort @$depends_on;
+like(
+ $depends_on->[0], qr{/ticket/2$},
+ "Check ticket link.",
+) or diag("'content' obtained:\n", $m->content);
+
+like(
+ $depends_on->[1], qr{/ticket/3$},
+ "Check ticket link.",
+) or diag("'content' obtained:\n", $m->content);
+
+$m->post(
+ "$baseurl/REST/1.0/ticket/2/links/show",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+);
+my ($link) = $m->content =~ m|DependedOnBy:.*ticket/(\d+)|;
+is($link, 1, "Check ticket link.") or diag("'content' obtained:\n", $m->content);
+
+$m->post(
+ "$baseurl/REST/1.0/ticket/3/links/show",
+ [
+ user => 'root',
+ pass => 'password',
+ ],
+ Content_Type => 'form-data',
+);
+($link) = $m->content =~ m|DependedOnBy:.*ticket/(\d+)|;
+is($link, 1, "Check ticket link.") or diag("'content' obtained:\n", $m->content);
diff --git a/rt/t/web/scrub.t b/rt/t/web/scrub.t
index 6483a7500..612c6e210 100644
--- a/rt/t/web/scrub.t
+++ b/rt/t/web/scrub.t
@@ -30,13 +30,13 @@ use Test::LongString;
{
my $html = q[<span lang=EN-US style='font-family:"Century Gothic","sans-serif";'>oh hai I'm some text</span>];
- my $expected = q[<span style="font-family:&quot;Century Gothic&quot;,&quot;sans-serif&quot;;">oh hai I'm some text</span>];
+ my $expected = q[<span lang="EN-US" style="font-family:&quot;Century Gothic&quot;,&quot;sans-serif&quot;;">oh hai I'm some text</span>];
is_string(scrub_html($html), $expected, "font lists");
}
{
my $html = q[<span lang=EN-US style='font-size:7.5pt;font-family:"Century Gothic","sans-serif";color:#666666;mso-fareast-language:IT'>oh hai I'm some text</span>];
- my $expected = q[<span style="font-size:7.5pt;font-family:&quot;Century Gothic&quot;,&quot;sans-serif&quot;;color:#666666;mso-fareast-language:IT">oh hai I'm some text</span>];
+ my $expected = q[<span lang="EN-US" style="font-size:7.5pt;font-family:&quot;Century Gothic&quot;,&quot;sans-serif&quot;;color:#666666;mso-fareast-language:IT">oh hai I'm some text</span>];
is_string(scrub_html($html), $expected, "outlook html");
}
diff --git a/rt/t/web/ticket_forward.t b/rt/t/web/ticket_forward.t
index be06ad976..1d74673de 100644
--- a/rt/t/web/ticket_forward.t
+++ b/rt/t/web/ticket_forward.t
@@ -227,6 +227,41 @@ diag "Forward Transaction with attachments but no 'content' part" if $ENV{TEST_V
like( $mail, qr/image\/png/, 'att image content type' );
}
}
+RT::Test->clean_caught_mails;
+
+diag "Forward Ticket Template with a Subject: line" if $ENV{TEST_VERBOSE};
+{
+
+ require RT::Template;
+ my $template = RT::Template->new($RT::SystemUser);
+ $template->Load('Forward Ticket');
+
+ # prepend a Subject: line
+ $template->SetContent("Subject: OVERRIDING SUBJECT\n\n" . $template->Content);
+
+ my $ticket = RT::Test->create_ticket(
+ Subject => 'test ticket',
+ Queue => 1,
+ );
+
+ $m->goto_ticket($ticket->Id);
+
+ $m->follow_link_ok(
+ { id => 'page-actions-forward' },
+ 'follow 1st Forward to forward ticket'
+ );
+
+ $m->submit_form(
+ form_name => 'ForwardMessage',
+ fields => {
+ To => 'rt-to@example.com',
+ },
+ button => 'ForwardAndReturn'
+ );
+
+ my ($mail) = RT::Test->fetch_caught_mails;
+ like($mail, qr/Subject: OVERRIDING SUBJECT/);
+}
undef $m;
done_testing;
diff --git a/rt/t/web/ticket_links.t b/rt/t/web/ticket_links.t
index cb30e92f9..efb615107 100644
--- a/rt/t/web/ticket_links.t
+++ b/rt/t/web/ticket_links.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use RT::Test tests => 106;
+use RT::Test tests => 146;
my ( $baseurl, $m ) = RT::Test->started_ok;
ok( $m->login, "Logged in" );
@@ -24,6 +24,16 @@ is( $deleted->Status, 'deleted', "deleted $deleted_id" );
$inactive->SetStatus('resolved');
is( $inactive->Status, 'resolved', 'resolved $inactive_id' );
+# Create an article for linking
+require RT::Class;
+my $class = RT::Class->new($RT::SystemUser);
+$class->Create(Name => 'test class');
+
+require RT::Article;
+my $article = RT::Article->new($RT::SystemUser);
+
+$article->Create(Class => $class->Id, Name => 'test article');
+
for my $type ( "DependsOn", "MemberOf", "RefersTo" ) {
for my $c (qw/base target/) {
my $id;
@@ -105,6 +115,59 @@ for my $type ( "DependsOn", "MemberOf", "RefersTo" ) {
);
$m->content_unlike( qr{$deleted_id.*?\[deleted\]}, "no deleted ticket",
);
+
+ diag "[$type]: Testing that reminders don't get copied for $c tickets";
+ {
+ my $ticket = RT::Test->create_ticket(
+ Subject => 'test ticket',
+ Queue => 1,
+ );
+
+ $m->goto_ticket($ticket->Id);
+ $m->form_name('UpdateReminders');
+ $m->field('NewReminder-Subject' => 'hello test reminder subject');
+ $m->click_button(value => 'Save');
+ $m->text_contains('hello test reminder subject');
+
+ my $id = $ticket->Id;
+ my $type_value = my $link_field = $type;
+ if ($c eq 'base') {
+ $type_value = "new-$type_value";
+ $link_field = "$link_field-$id";
+ }
+ else {
+ $type_value = "$type_value-new";
+ $link_field = "$id-$link_field";
+ }
+
+ if ($type eq 'RefersTo') {
+ $m->goto_ticket($ticket->Id);
+ $m->follow_link(id => 'page-links');
+
+ # add $baseurl as a link
+ $m->form_name('ModifyLinks');
+ $m->field($link_field => "$baseurl/test_ticket_reference");
+ $m->click('SubmitTicket');
+
+ # add an article as a link
+ $m->form_name('ModifyLinks');
+ $m->field($link_field => 'a:' . $article->Id);
+ $m->click('SubmitTicket');
+ }
+
+ my $depends_on_url = sprintf(
+ '%s/Ticket/Create.html?Queue=%s&CloneTicket=%s&%s=%s',
+ $baseurl, '1', $id, $type_value, $id,
+ );
+ $m->get_ok($depends_on_url);
+ $m->form_name('TicketCreate');
+ $m->click_button(value => 'Create');
+ $m->content_lacks('hello test reminder subject');
+ if ($type eq 'RefersTo') {
+ $m->text_contains("$baseurl/test_ticket_reference");
+ $m->text_contains("Article " . $article->Id . ': test article');
+ }
+ }
}
}