summaryrefslogtreecommitdiff
path: root/rt/t/web
diff options
context:
space:
mode:
Diffstat (limited to 'rt/t/web')
-rw-r--r--rt/t/web/action-results.t48
-rw-r--r--rt/t/web/admin_queue_lifecycle.t49
-rw-r--r--rt/t/web/attachment_encoding.t41
-rw-r--r--rt/t/web/basic.t5
-rw-r--r--rt/t/web/cf_date.t81
-rw-r--r--rt/t/web/cf_datetime.t86
-rw-r--r--rt/t/web/cf_values_class.t54
-rw-r--r--rt/t/web/command_line_cf_edge_cases.t87
-rw-r--r--rt/t/web/compilation_errors.t1
-rw-r--r--rt/t/web/current_user_outdated_email.t41
-rw-r--r--rt/t/web/helpers-http-cache-headers.t96
-rw-r--r--rt/t/web/html_template.t46
-rw-r--r--rt/t/web/login.t133
-rw-r--r--rt/t/web/offline_messages_utf8.t5
-rw-r--r--rt/t/web/offline_utf8.t13
-rw-r--r--rt/t/web/plugin-overlays.t30
-rw-r--r--rt/t/web/query_builder.t1
-rw-r--r--rt/t/web/rest-non-ascii-subject.t5
-rw-r--r--rt/t/web/sidebyside_layout.t45
-rw-r--r--rt/t/web/ticket-create-utf8.t2
-rw-r--r--rt/t/web/ticket_txn_subject.t85
-rw-r--r--rt/t/web/user_update.t10
22 files changed, 893 insertions, 71 deletions
diff --git a/rt/t/web/action-results.t b/rt/t/web/action-results.t
new file mode 100644
index 000000000..db8c26bb8
--- /dev/null
+++ b/rt/t/web/action-results.t
@@ -0,0 +1,48 @@
+use strict;
+use warnings;
+use RT::Test tests => 'no_declare';
+
+my ($url, $m) = RT::Test->started_ok;
+
+ok $m->login, "Logged in";
+
+# We test two ticket creation paths since one historically doesn't update the
+# session (quick create) and the other does.
+for my $quick (1, 0) {
+ diag $quick ? "Quick ticket creation" : "Normal ticket creation";
+
+ $m->get_ok("/");
+ $m->submit_form_ok({ form_name => 'CreateTicketInQueue' }, "Create new ticket form")
+ unless $quick;
+ $m->submit_form_ok({
+ with_fields => {
+ Subject => "The Plants",
+ Content => "Please water them.",
+ },
+ }, "Submitted new ticket");
+
+ my $id = RT::Test->last_ticket->id;
+
+ like $m->uri, qr/results=[A-Za-z0-9]{32}/, "URI contains results hash";
+ $m->content_contains("Ticket $id created", "Page contains results message");
+ $m->content_contains("#$id: The Plants") unless $quick;
+
+ diag "Reloading without a referer but with a results hash doesn't trigger the CSRF"; {
+ # Mech's API here sucks. To drop the Referer and simulate a real browser
+ # reload, we need to make a new request which explicitly adds an empty Referer
+ # header (causing it to never be sent) and then deletes the empty Referer
+ # header to let it be automatically managed again.
+ $m->add_header("Referer" => undef);
+ $m->get_ok( $m->uri, "Reloading the results page without a Referer" );
+ $m->delete_header("Referer");
+
+ like $m->uri, qr/results=[A-Za-z0-9]{32}/, "URI contains results hash";
+ $m->content_lacks("cross-site request forgery", "Skipped the CSRF interstitial")
+ or $m->follow_link_ok({ text => "click here to resume your request" }, "Ignoring CSRF warning");
+ $m->content_lacks("Ticket $id created", "Page lacks results message");
+ $m->content_contains("#$id: The Plants") unless $quick;
+ }
+}
+
+undef $m;
+done_testing;
diff --git a/rt/t/web/admin_queue_lifecycle.t b/rt/t/web/admin_queue_lifecycle.t
new file mode 100644
index 000000000..295e9ea57
--- /dev/null
+++ b/rt/t/web/admin_queue_lifecycle.t
@@ -0,0 +1,49 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 13;
+
+my $lifecycles = RT->Config->Get('Lifecycles');
+RT->Config->Set( Lifecycles => %{$lifecycles},
+ foo => {
+ initial => ['initial'],
+ active => ['open'],
+ inactive => ['resolved'],
+ }
+);
+
+RT::Lifecycle->FillCache();
+
+my ( $url, $m ) = RT::Test->started_ok;
+ok( $m->login(), 'logged in' );
+
+$m->get_ok( $url . '/Admin/Queues/Modify.html?id=1' );
+
+my $form = $m->form_name('ModifyQueue');
+my $lifecycle_input = $form->find_input('Lifecycle');
+is( $lifecycle_input->value, 'default', 'default lifecycle' );
+
+my @lifecycles = sort $lifecycle_input->possible_values;
+is_deeply( \@lifecycles, [qw/approvals default foo/], 'found all lifecycles' );
+
+$m->submit_form();
+$m->content_lacks( 'Lifecycle changed from',
+ 'no message of "Lifecycle changed from"' );
+$m->content_lacks( 'That is already the current value',
+ 'no message of "That is already the current value"' );
+
+$form = $m->form_name('ModifyQueue');
+$m->submit_form( fields => { Lifecycle => 'foo' }, );
+$m->content_contains(
+ 'Lifecycle changed from "default" to "foo"');
+$lifecycle_input = $form->find_input('Lifecycle');
+is( $lifecycle_input->value, 'foo', 'lifecycle is changed to foo' );
+
+$form = $m->form_name('ModifyQueue');
+$m->submit_form( fields => { Lifecycle => 'default' }, );
+$m->content_contains(
+ 'Lifecycle changed from "foo" to "default"');
+$lifecycle_input = $form->find_input('Lifecycle');
+is( $lifecycle_input->value, 'default',
+ 'lifecycle is changed back to default' );
+
diff --git a/rt/t/web/attachment_encoding.t b/rt/t/web/attachment_encoding.t
index 5af7fda20..f49720e0f 100644
--- a/rt/t/web/attachment_encoding.t
+++ b/rt/t/web/attachment_encoding.t
@@ -3,14 +3,15 @@ use strict;
use warnings;
use RT::Test tests => 32;
-use Encode;
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
-use utf8;
-
use File::Spec;
+my $subject = Encode::decode("UTF-8",'标题');
+my $content = Encode::decode("UTF-8",'测试');
+my $filename = Encode::decode("UTF-8",'附件.txt');
+
diag 'test without attachments' if $ENV{TEST_VERBOSE};
{
@@ -19,13 +20,13 @@ diag 'test without attachments' if $ENV{TEST_VERBOSE};
$m->form_name('TicketModify');
$m->submit_form(
form_number => 3,
- fields => { Subject => '标题', Content => '测试' },
+ fields => { Subject => $subject, Content => $content },
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
$m->follow_link_ok( { text => 'with headers' },
'-> /Ticket/Attachment/WithHeaders/...' );
- $m->content_contains( '标题', 'has subject 标题' );
- $m->content_contains( '测试', 'has content 测试' );
+ $m->content_contains( $subject, "has subject $subject" );
+ $m->content_contains( $content, "has content $content" );
my ( $id ) = $m->uri =~ /(\d+)$/;
ok( $id, 'found attachment id' );
@@ -35,8 +36,8 @@ diag 'test without attachments' if $ENV{TEST_VERBOSE};
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
- $m->content_contains( '标题', 'has subject 标题' );
- $m->content_contains( '测试', 'has content 测试' );
+ $m->content_contains( $subject, "has subject $subject" );
+ $m->content_contains( $content, "has content $content" );
}
diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
@@ -44,10 +45,10 @@ diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
{
my $file =
- File::Spec->catfile( RT::Test->temp_directory, encode_utf8 '附件.txt' );
+ File::Spec->catfile( RT::Test->temp_directory, Encode::encode("UTF-8",$filename) );
open( my $fh, '>', $file ) or die $!;
binmode $fh, ':utf8';
- print $fh '附件';
+ print $fh $filename;
close $fh;
$m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
@@ -55,17 +56,17 @@ diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
$m->form_name('TicketModify');
$m->submit_form(
form_number => 3,
- fields => { Subject => '标题', Content => '测试', Attach => $file },
+ fields => { Subject => $subject, Content => $content, Attach => $file },
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
- $m->content_contains( '附件.txt', 'attached filename' );
- $m->content_lacks( encode_utf8 '附件.txt', 'no double encoded attached filename' );
+ $m->content_contains( $filename, 'attached filename' );
+ $m->content_lacks( Encode::encode("UTF-8",$filename), 'no double encoded attached filename' );
$m->follow_link_ok( { text => 'with headers' },
'-> /Ticket/Attachment/WithHeaders/...' );
# subject is in the parent attachment, so there is no 标题
- $m->content_lacks( '标题', 'does not have content 标题' );
- $m->content_contains( '测试', 'has content 测试' );
+ $m->content_lacks( $subject, "does not have content $subject" );
+ $m->content_contains( $content, "has content $content" );
my ( $id ) = $m->uri =~ /(\d+)$/;
ok( $id, 'found attachment id' );
@@ -75,15 +76,15 @@ diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
- $m->content_lacks( '标题', 'does not have content 标题' );
- $m->content_contains( '测试', 'has content 测试' );
+ $m->content_lacks( $subject, "does not have content $subject" );
+ $m->content_contains( $content, "has content $content" );
$m->back;
$m->back;
- $m->follow_link_ok( { text => 'Download 附件.txt' },
+ $m->follow_link_ok( { text => "Download $filename" },
'-> /Ticket/Attachment/...' );
- $m->content_contains( '附件', 'has content 附件' );
+ $m->content_contains( $filename, "has file content $filename" );
( $id ) = $m->uri =~ /(\d+)\D+$/;
ok( $id, 'found attachment id' );
@@ -94,7 +95,7 @@ diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
ok( $attachment->SetHeader( 'X-RT-Original-Encoding' => 'gbk' ),
'set original encoding to gbk' );
$m->get( $m->uri );
- $m->content_contains( '附件', 'has content 附件' );
+ $m->content_contains( $filename, "has content $filename" );
unlink $file;
}
diff --git a/rt/t/web/basic.t b/rt/t/web/basic.t
index e61e80e9c..02483b208 100644
--- a/rt/t/web/basic.t
+++ b/rt/t/web/basic.t
@@ -1,7 +1,6 @@
use strict;
use warnings;
-use Encode;
use RT::Test tests => 23;
@@ -27,7 +26,7 @@ my $url = $agent->rt_base_url;
$agent->goto_create_ticket(1);
is ($agent->status, 200, "Loaded Create.html");
$agent->form_name('TicketCreate');
- my $string = Encode::decode_utf8("I18N Web Testing æøå");
+ my $string = Encode::decode("UTF-8","I18N Web Testing æøå");
$agent->field('Subject' => "Ticket with utf8 body");
$agent->field('Content' => $string);
ok($agent->submit, "Created new ticket with $string as Content");
@@ -49,7 +48,7 @@ my $url = $agent->rt_base_url;
is ($agent->status, 200, "Loaded Create.html");
$agent->form_name('TicketCreate');
- my $string = Encode::decode_utf8("I18N Web Testing æøå");
+ my $string = Encode::decode( "UTF-8","I18N Web Testing æøå");
$agent->field('Subject' => $string);
$agent->field('Content' => "Ticket with utf8 subject");
ok($agent->submit, "Created new ticket with $string as Content");
diff --git a/rt/t/web/cf_date.t b/rt/t/web/cf_date.t
index e69833c13..2180e140f 100644
--- a/rt/t/web/cf_date.t
+++ b/rt/t/web/cf_date.t
@@ -189,4 +189,85 @@ diag 'check invalid inputs';
is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} );
}
+diag 'retain values when adding attachments';
+{
+ my ( $ticket, $id );
+
+ my $txn_cf = RT::CustomField->new( RT->SystemUser );
+ my ( $ret, $msg ) = $txn_cf->Create(
+ Name => 'test txn cf date',
+ TypeComposite => 'Date-1',
+ LookupType => 'RT::Queue-RT::Ticket-RT::Transaction',
+ );
+ ok( $ret, "created 'txn datetime': $msg" );
+ $txn_cf->AddToObject(RT::Queue->new(RT->SystemUser));
+ my $txn_cfid = $txn_cf->id;
+
+ $m->submit_form(
+ form_name => "CreateTicketInQueue",
+ fields => { Queue => 'General' },
+ );
+ $m->content_contains('test cf date', 'has cf' );
+ $m->content_contains('test txn cf date', 'has txn cf' );
+
+ $m->submit_form_ok(
+ {
+ form_name => "TicketCreate",
+ fields => {
+ Subject => 'test 2015-06-04',
+ Content => 'test',
+ "Object-RT::Ticket--CustomField-$cfid-Values" => '2015-06-04',
+ "Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-08-15',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'create test ticket'
+ );
+ $m->form_name("TicketCreate");
+ is( $m->value( "Object-RT::Ticket--CustomField-$cfid-Values" ),
+ "2015-06-04", "ticket cf date value still on form" );
+ is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+ "2015-08-15", "txn cf date date value still on form" );
+
+ $m->submit_form();
+ ok( ($id) = $m->content =~ /Ticket (\d+) created/, "created ticket $id" );
+
+ $m->follow_link_ok( {text => 'Reply'} );
+ $m->title_like( qr/Update/ );
+ $m->content_contains('test txn cf date', 'has txn cf');
+ $m->submit_form_ok(
+ {
+ form_name => "TicketUpdate",
+ fields => {
+ Content => 'test',
+ "Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-09-16',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'Update test ticket'
+ );
+ $m->form_name("TicketUpdate");
+ is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+ "2015-09-16", "txn date value still on form" );
+
+ $m->follow_link_ok( {text => 'Jumbo'} );
+ $m->title_like( qr/Jumbo/ );
+
+ $m->submit_form_ok(
+ {
+ form_name => "TicketModifyAll",
+ fields => {
+ "Object-RT::Transaction--CustomField-$txn_cfid-Values" =>
+ '2015-12-16',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'jumbo form'
+ );
+
+ $m->form_name("TicketModifyAll");
+ is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+ "2015-12-16", "txn date value still on form" );
+}
+
done_testing;
diff --git a/rt/t/web/cf_datetime.t b/rt/t/web/cf_datetime.t
index 4580c4a4f..72a8b3f7e 100644
--- a/rt/t/web/cf_datetime.t
+++ b/rt/t/web/cf_datetime.t
@@ -215,6 +215,92 @@ diag 'check invalid inputs';
is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} );
}
+diag 'retain values when adding attachments';
+{
+ my ( $ticket, $id );
+
+ my $txn_cf = RT::CustomField->new( RT->SystemUser );
+ my ( $ret, $msg ) = $txn_cf->Create(
+ Name => 'test txn cf datetime',
+ TypeComposite => 'DateTime-1',
+ LookupType => 'RT::Queue-RT::Ticket-RT::Transaction',
+ );
+ ok( $ret, "created 'txn datetime': $msg" );
+ $txn_cf->AddToObject(RT::Queue->new(RT->SystemUser));
+ my $txn_cfid = $txn_cf->id;
+
+ $m->submit_form(
+ form_name => "CreateTicketInQueue",
+ fields => { Queue => 'General' },
+ );
+ $m->content_contains('test cf datetime', 'has cf' );
+ $m->content_contains('test txn cf datetime', 'has txn cf' );
+
+ $m->submit_form_ok(
+ {
+ form_name => "TicketCreate",
+ fields => {
+ Subject => 'test 2015-06-04',
+ Content => 'test',
+ "Object-RT::Ticket--CustomField-$cfid-Values" => '2015-06-04 08:30:00',
+ "Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-08-15 12:30:30',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'Create test ticket'
+ );
+ $m->form_name("TicketCreate");
+ is( $m->value( "Object-RT::Ticket--CustomField-$cfid-Values" ),
+ "2015-06-04 08:30:00", "ticket cf date value still on form" );
+ $m->content_contains( "Jun 04 08:30:00 2015", 'date in parens' );
+ is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+ "2015-08-15 12:30:30", "txn cf date date value still on form" );
+ $m->content_contains( "Aug 15 12:30:30 2015", 'date in parens' );
+
+ $m->submit_form();
+ ok( ($id) = $m->content =~ /Ticket (\d+) created/, "Created ticket $id" );
+
+ $m->follow_link_ok( {text => 'Reply'} );
+ $m->title_like( qr/Update/ );
+ $m->content_contains('test txn cf date', 'has txn cf');
+ $m->submit_form_ok(
+ {
+ form_name => "TicketUpdate",
+ fields => {
+ Content => 'test',
+ "Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-09-16 09:30:40',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'Update test ticket'
+ );
+ $m->form_name("TicketUpdate");
+ is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+ "2015-09-16 09:30:40", "Date value still on form" );
+ $m->content_contains( "Sep 16 09:30:40 2015", 'date in parens' );
+
+ $m->follow_link_ok( {text => 'Jumbo'} );
+ $m->title_like( qr/Jumbo/ );
+
+ $m->submit_form_ok(
+ {
+ form_name => "TicketModifyAll",
+ fields => {
+ "Object-RT::Transaction--CustomField-$txn_cfid-Values" =>
+ '2015-12-16 03:00:00',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'jumbo form'
+ );
+ $m->save_content('/tmp/x.html');
+
+ $m->form_name("TicketModifyAll");
+ is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
+ "2015-12-16 03:00:00", "txn date value still on form" );
+ $m->content_contains( "Dec 16 03:00:00 2015", 'date in parens' );
+}
+
sub is_results_number {
local $Test::Builder::Level = $Test::Builder::Level + 1;
my $fields = shift;
diff --git a/rt/t/web/cf_values_class.t b/rt/t/web/cf_values_class.t
new file mode 100644
index 000000000..646642781
--- /dev/null
+++ b/rt/t/web/cf_values_class.t
@@ -0,0 +1,54 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 8;
+
+use constant VALUES_CLASS => 'RT::CustomFieldValues::Groups';
+RT->Config->Set(CustomFieldValuesSources => VALUES_CLASS);
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in as root';
+
+my $cf_name = 'test values class';
+
+my $cfid;
+diag "Create a CF";
+{
+ $m->follow_link( id => 'tools-config-custom-fields-create');
+ $m->submit_form(
+ form_name => "ModifyCustomField",
+ fields => {
+ Name => $cf_name,
+ TypeComposite => 'Select-1',
+ LookupType => 'RT::Queue-RT::Ticket',
+ },
+ );
+ $m->content_contains('Object created', 'created Select-1' );
+ $cfid = $m->form_name('ModifyCustomField')->value('id');
+ ok $cfid, "found id of the CF in the form, it's #$cfid";
+}
+
+diag "change to external values class";
+{
+ $m->submit_form(
+ form_name => "ModifyCustomField",
+ fields => { ValuesClass => 'RT::CustomFieldValues::Groups', },
+ button => 'Update',
+ );
+ $m->content_contains(
+ "Field values source changed from 'RT::CustomFieldValues' to 'RT::CustomFieldValues::Groups'",
+ 'changed to external values class' );
+}
+
+diag "change to internal values class";
+{
+ $m->submit_form(
+ form_name => "ModifyCustomField",
+ fields => { ValuesClass => 'RT::CustomFieldValues', },
+ button => 'Update',
+ );
+ $m->content_contains(
+ "Field values source changed from 'RT::CustomFieldValues::Groups' to 'RT::CustomFieldValues'",
+ 'changed to internal values class' );
+}
+
diff --git a/rt/t/web/command_line_cf_edge_cases.t b/rt/t/web/command_line_cf_edge_cases.t
new file mode 100644
index 000000000..d7c777768
--- /dev/null
+++ b/rt/t/web/command_line_cf_edge_cases.t
@@ -0,0 +1,87 @@
+use strict;
+use warnings;
+use Test::Expect;
+use RT::Test tests => 100, actual_server => 1;
+my ( $baseurl, $m ) = RT::Test->started_ok;
+
+my $rt_tool_path = "$RT::BinPath/rt";
+
+$ENV{'RTUSER'} = 'root';
+$ENV{'RTPASSWD'} = 'password';
+$ENV{'RTSERVER'} = RT->Config->Get('WebBaseURL');
+$ENV{'RTDEBUG'} = '1';
+$ENV{'RTCONFIG'} = '/dev/null';
+
+my @cfs = (
+ 'foo=bar', 'foo.bar', 'foo:bar', 'foo bar',
+ 'foo{bar}', 'foo-bar', 'foo()bar',
+);
+for my $name (@cfs) {
+ RT::Test->load_or_create_custom_field(
+ Name => $name,
+ Type => 'Freeform',
+ MaxValues => 1,
+ Queue => 0,
+ );
+}
+
+expect_run(
+ command => "$rt_tool_path shell",
+ prompt => 'rt> ',
+ quit => 'quit',
+);
+
+# create a ticket
+for my $name (@cfs) {
+ expect_send(
+qq{create -t ticket set subject='test cf $name' 'CF.{$name}=foo:b a.r=baz'},
+ "creating a ticket for cf $name"
+ );
+
+ expect_handle->before() =~ /Ticket (\d+) created/;
+ my $ticket_id = $1;
+
+ expect_send( "show ticket/$ticket_id -f 'CF.{$name}'",
+ 'checking new value' );
+ expect_like( qr/CF\.{\Q$name\E}: foo:b a\.r=baz/i, 'verified change' );
+
+ expect_send( "edit ticket/$ticket_id set 'CF.{$name}=bar'",
+ "changing cf $name to bar" );
+ expect_like( qr/Ticket $ticket_id updated/, 'changed cf' );
+ expect_send( "show ticket/$ticket_id -f 'CF.{$name}'",
+ 'checking new value' );
+ expect_like( qr/CF\.{\Q$name\E}: bar/i, 'verified change' );
+
+ expect_send(
+qq{create -t ticket set subject='test cf $name' 'CF-$name=foo:b a.r=baz'},
+ "creating a ticket for cf $name"
+ );
+ expect_handle->before() =~ /Ticket (\d+) created/;
+ $ticket_id = $1;
+
+ expect_send( "show ticket/$ticket_id -f 'CF-$name'", 'checking new value' );
+ if ( $name eq 'foo=bar' ) {
+ expect_like( qr/CF\.{\Q$name\E}: $/mi,
+ "can't use = in cf name with old style" );
+ }
+ else {
+ expect_like( qr/CF\.{\Q$name\E}: foo:b a\.r=baz/i, 'verified change' );
+ expect_send( "edit ticket/$ticket_id set 'CF-$name=bar'",
+ "changing cf $name to bar" );
+ expect_like( qr/Ticket $ticket_id updated/, 'changed cf' );
+ expect_send( "show ticket/$ticket_id -f 'CF-$name'",
+ 'checking new value' );
+ expect_like( qr/CF\.{\Q$name\E}: bar/i, 'verified change' );
+ }
+}
+
+my @invalid = ('foo,bar');
+for my $name (@invalid) {
+ expect_send(
+ qq{create -t ticket set subject='test cf $name' 'CF.{$name}=foo'},
+ "creating a ticket for cf $name" );
+ expect_like( qr/You shouldn't specify objects as arguments to create/i,
+ '$name is not a valid cf name' );
+}
+
+expect_quit();
diff --git a/rt/t/web/compilation_errors.t b/rt/t/web/compilation_errors.t
index 0ae6ead5b..126d33691 100644
--- a/rt/t/web/compilation_errors.t
+++ b/rt/t/web/compilation_errors.t
@@ -15,7 +15,6 @@ BEGIN {
use HTTP::Request::Common;
use HTTP::Cookies;
use LWP;
-use Encode;
my $cookie_jar = HTTP::Cookies->new;
diff --git a/rt/t/web/current_user_outdated_email.t b/rt/t/web/current_user_outdated_email.t
new file mode 100644
index 000000000..51fc803c6
--- /dev/null
+++ b/rt/t/web/current_user_outdated_email.t
@@ -0,0 +1,41 @@
+
+use strict;
+use warnings;
+use RT::Test tests => 39;
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+$m->login();
+
+my @links = (
+ '/', '/Ticket/Create.html?Queue=1',
+ '/SelfService/Create.html?Queue=1', '/m/ticket/create?Queue=1'
+);
+
+my $root = RT::Test->load_or_create_user( Name => 'root' );
+ok( $root->id, 'loaded root' );
+is( $root->EmailAddress, 'root@localhost', 'default root email' );
+
+for my $link (@links) {
+ $m->get_ok($link);
+ $m->content_contains( '"root@localhost"', "default email in $link" );
+}
+
+$root->SetEmailAddress('foo@example.com');
+is( $root->EmailAddress, 'foo@example.com', 'changed to foo@example.com' );
+
+for my $link (@links) {
+ $m->get_ok($link);
+ $m->content_lacks( '"root@localhost"', "no default email in $link" );
+ $m->content_contains( '"foo@example.com"', "new email in $link" );
+}
+
+$root->SetEmailAddress('root@localhost');
+is( $root->EmailAddress, 'root@localhost', 'changed back to root@localhost' );
+
+for my $link (@links) {
+ $m->get_ok($link);
+ $m->content_lacks( '"foo@example.com"', "no previous email in $link" );
+ $m->content_contains( '"root@localhost"', "default email in $link" );
+}
+
diff --git a/rt/t/web/helpers-http-cache-headers.t b/rt/t/web/helpers-http-cache-headers.t
new file mode 100644
index 000000000..1731e9d17
--- /dev/null
+++ b/rt/t/web/helpers-http-cache-headers.t
@@ -0,0 +1,96 @@
+use strict;
+use warnings;
+
+# trs: I'd write a quick t/web/caching-headers.t file which loops the available
+# endpoints checking for the right headers.
+
+use File::Find;
+
+BEGIN {
+ # Ensure that the test and server processes use the same fixed time.
+ use constant TIME => 1365175699;
+ use Test::MockTime 'set_fixed_time';
+ set_fixed_time(TIME);
+
+ use RT::Test
+ tests => undef,
+ config => "use Test::MockTime 'set_fixed_time'; set_fixed_time(".TIME.");";
+}
+
+my ($base, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+my $docroot = join '/', qw(share html);
+
+# find endpoints to loop over
+my @endpoints = ('/NoAuth/css/print.css');
+find({
+ wanted => sub {
+ if ( -f $_ && $_ !~ m|autohandler$| ) {
+ ( my $endpoint = $_ ) =~ s|^$docroot||;
+ push @endpoints, $endpoint;
+ }
+ },
+ no_chdir => 1,
+} => join '/', $docroot => 'Helpers');
+
+my $ticket_id;
+diag "create a ticket via the API";
+{
+ my $ticket = RT::Ticket->new( RT->SystemUser );
+ my ($id, $txn, $msg) = $ticket->Create(
+ Queue => 'General',
+ Subject => 'test ticket',
+ );
+ ok $id, 'created a ticket #'. $id or diag "error: $msg";
+ is $ticket->Subject, 'test ticket', 'correct subject';
+ $ticket_id = $id;
+}
+
+
+my $expected;
+diag "set up expected date headers";
+{
+
+ # expected headers
+ $expected = {
+ Autocomplete => {
+ 'Cache-Control' => 'max-age=120, private',
+ 'Expires' => 'Fri, 5 Apr 2013 15:30:19 GMT',
+ },
+ NoAuth => {
+ 'Cache-Control' => 'max-age=2592000, public',
+ 'Expires' => 'Sun, 5 May 2013 15:28:19 GMT',
+ },
+ default => {
+ 'Cache-Control' => 'no-cache',
+ 'Expires' => 'Fri, 5 Apr 2013 15:28:19 GMT',
+ },
+ };
+
+}
+
+foreach my $endpoint ( @endpoints ) {
+ $m->get_ok( $endpoint . "?id=${ticket_id}&Status=open&Requestor=root" );
+
+ my $header_key = 'default';
+ if ( $endpoint =~ m|Autocomplete| ) {
+ $header_key = 'Autocomplete';
+ } elsif ( $endpoint =~ m|NoAuth| ) {
+ $header_key = 'NoAuth';
+ }
+ my $headers = $expected->{$header_key};
+
+ is(
+ $m->res->header('Cache-Control') => $headers->{'Cache-Control'},
+ 'got expected Cache-Control header'
+ );
+
+ is(
+ $m->res->header('Expires') => $headers->{'Expires'},
+ 'got expected Expires header'
+ );
+}
+
+undef $m;
+done_testing;
diff --git a/rt/t/web/html_template.t b/rt/t/web/html_template.t
index 78b95a3b2..a2764556f 100644
--- a/rt/t/web/html_template.t
+++ b/rt/t/web/html_template.t
@@ -2,16 +2,16 @@
use strict;
use warnings;
-use RT::Test tests => 19;
-use Encode;
+use RT::Test tests => undef;
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
-use utf8;
-
diag('make Autoreply template a html one and add utf8 chars')
if $ENV{TEST_VERBOSE};
+my $template = Encode::decode("UTF-8", "你好 éèà€");
+my $subject = Encode::decode("UTF-8", "标题");
+my $content = Encode::decode("UTF-8", "测试");
{
$m->follow_link_ok( { id => 'tools-config-global-templates' }, '-> Templates' );
$m->follow_link_ok( { text => 'Autoreply' }, '-> Autoreply' );
@@ -19,20 +19,20 @@ diag('make Autoreply template a html one and add utf8 chars')
$m->submit_form(
form_name => 'ModifyTemplate',
fields => {
- Content => <<'EOF',
-Subject: AutoReply: {$Ticket->Subject}
+ Content => <<EOF,
+Subject: AutoReply: {\$Ticket->Subject}
Content-Type: text/html
-你好 éèà€
-{$Ticket->Subject}
+$template
+{\$Ticket->Subject}
-------------------------------------------------------------------------
-{$Transaction->Content()}
+{\$Transaction->Content()}
EOF
},
);
$m->content_like( qr/Content updated/, 'content is changed' );
- $m->content_contains( '你好', 'content is really updated' );
+ $m->content_contains( $template, 'content is really updated' );
}
diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE};
@@ -42,17 +42,16 @@ diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE};
$m->submit_form(
form_name => 'TicketCreate',
- fields => { Subject => '标题', Content => '<h1>测试</h1>',
+ fields => { Subject => $subject, Content => "<h1>$content</h1>",
ContentType => 'text/html' },
);
$m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
$m->follow_link( text => 'Show' );
- $m->content_contains( '你好', 'html has 你好' );
- $m->content_contains( 'éèà€', 'html has éèà€' );
- $m->content_contains( '标题',
- 'html has ticket subject 标题' );
- $m->content_contains( '&lt;h1&gt;测试&lt;/h1&gt;',
- 'html has ticket html content 测试' );
+ $m->content_contains( $template, "html has $template" );
+ $m->content_contains( $subject,
+ "html has ticket subject $subject" );
+ $m->content_contains( "&lt;h1&gt;$content&lt;/h1&gt;",
+ "html has ticket html content $content" );
}
diag('test real mail outgoing') if $ENV{TEST_VERBOSE};
@@ -61,11 +60,12 @@ diag('test real mail outgoing') if $ENV{TEST_VERBOSE};
# $mail is utf8 encoded
my ($mail) = RT::Test->fetch_caught_mails;
- $mail = decode_utf8 $mail;
- like( $mail, qr/你好.*你好/s, 'mail has éèà€' );
- like( $mail, qr/éèà€.*éèà€/s, 'mail has éèà€' );
- like( $mail, qr/标题.*标题/s, 'mail has ticket subject 标题' );
- like( $mail, qr/测试.*测试/s, 'mail has ticket content 测试' );
- like( $mail, qr!<h1>测试</h1>!, 'mail has ticket html content 测试' );
+ $mail = Encode::decode("UTF-8", $mail );
+ like( $mail, qr/$template.*$template/s, 'mail has template content $template twice' );
+ like( $mail, qr/$subject.*$subject/s, 'mail has ticket subject $sujbect twice' );
+ like( $mail, qr/$content.*$content/s, 'mail has ticket content $content twice' );
+ like( $mail, qr!<h1>$content</h1>!, 'mail has ticket html content <h1>$content</h1>' );
}
+undef $m;
+done_testing;
diff --git a/rt/t/web/login.t b/rt/t/web/login.t
new file mode 100644
index 000000000..d0213c373
--- /dev/null
+++ b/rt/t/web/login.t
@@ -0,0 +1,133 @@
+use strict;
+use warnings;
+
+use RT::Test tests => 34;
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+
+my $ticket = RT::Test->create_ticket(
+ Subject => 'ticket_foo',
+ Queue => 'General',
+);
+
+my ( $user, $pass ) = ( 'root', 'password' );
+
+diag "normal login";
+{
+ $m->get($baseurl);
+ $m->title_is('Login');
+ is( $m->uri, $baseurl, "right url" );
+
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => 'wrong pass',
+ }
+ );
+ $m->content_contains( "Your username or password is incorrect",
+ 'login error message' );
+ $m->warning_like( qr/FAILED LOGIN for root/,
+ "got failed login warning" );
+
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+
+ $m->title_is( 'RT at a glance', 'logged in' );
+
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+ $m->title_is( 'Logout', 'logout' );
+}
+
+diag "tangent login";
+
+{
+ $m->get( $baseurl . '/Ticket/Display.html?id=1' );
+ $m->title_is('Login');
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ like( $m->uri, qr{/Ticket/Display\.html}, 'normal ticket page' );
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+}
+
+diag "mobile login with not mobile client";
+{
+ $m->get( $baseurl . '/m' );
+ is( $m->uri, $baseurl . '/m', "right url" );
+ $m->content_contains( "/m/index.html?NotMobile=1", 'mobile login' );
+
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => 'wrong pass',
+ }
+ );
+ $m->content_contains( "Your username or password is incorrect",
+ 'login error message' );
+ $m->warning_like( qr/FAILED LOGIN for root/,
+ "got failed login warning" );
+
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ like( $m->uri, qr{\Q$baseurl/m\E}, "mobile url" );
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+ $m->content_contains( "/m/index.html?NotMobile=1",
+ 'back to mobile login page' );
+ $m->content_lacks( 'Logout', 'really logout' );
+}
+
+
+diag "mobile normal login";
+{
+
+ # default browser in android 2.3.6
+ $m->agent(
+"Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus One Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
+ );
+
+ $m->get($baseurl);
+ is( $m->uri, $baseurl, "right url" );
+ $m->content_contains( "/m/index.html?NotMobile=1", 'mobile login' );
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ is( $m->uri, $baseurl . '/m/', "mobile url" );
+ $m->follow_link_ok( { text => 'Logout' }, 'follow logout' );
+ $m->content_contains( "/m/index.html?NotMobile=1", 'back to mobile login page' );
+ $m->content_lacks( 'Logout', 'really logout' );
+}
+
+diag "mobile tangent login";
+{
+ $m->get( $baseurl . '/Ticket/Display.html?id=1' );
+ $m->content_contains( "/m/index.html?NotMobile=1", 'mobile login' );
+ $m->submit_form(
+ form_id => 'login',
+ fields => {
+ user => $user,
+ pass => $pass,
+ }
+ );
+ like( $m->uri, qr{/m/ticket/show}, 'mobile ticket page' );
+}
+
diff --git a/rt/t/web/offline_messages_utf8.t b/rt/t/web/offline_messages_utf8.t
index 4518c7b7a..4cf6954bd 100644
--- a/rt/t/web/offline_messages_utf8.t
+++ b/rt/t/web/offline_messages_utf8.t
@@ -2,7 +2,6 @@ use strict;
use warnings;
use RT::Test tests => 8;
-use Encode;
use RT::Ticket;
my ( $url, $m ) = RT::Test->started_ok;
@@ -35,7 +34,7 @@ EOF
fields => { string => $template, },
button => 'UpdateTickets',
);
- my $content = encode 'utf8', $m->content;
+ my $content = Encode::encode("UTF-8", $m->content);
ok( $content =~ m/申請單 #(\d+) 成功新增於 &#39;General&#39; 表單/, 'message is shown right' );
$ticket_id = $1;
}
@@ -55,7 +54,7 @@ EOF
button => 'UpdateTickets',
);
- my $content = encode 'utf8', $m->content;
+ my $content = Encode::encode("UTF-8", $m->content);
ok(
$content =~
qr/主題\s*的值從\s*&#39;test message&#39;\s*改為\s*&#39;test message update&#39;/,
diff --git a/rt/t/web/offline_utf8.t b/rt/t/web/offline_utf8.t
index c317a4616..aab3049a3 100644
--- a/rt/t/web/offline_utf8.t
+++ b/rt/t/web/offline_utf8.t
@@ -2,14 +2,11 @@ use strict;
use warnings;
use RT::Test tests => 9;
-use utf8;
-
-use Encode;
use RT::Ticket;
my $file = File::Spec->catfile( RT::Test->temp_directory, 'template' );
open my $fh, '>', $file or die $!;
-my $template = <<EOF;
+my $template = Encode::decode("UTF-8",<<EOF);
===Create-Ticket: ticket1
Queue: General
Subject: 标题
@@ -19,7 +16,7 @@ Content:
ENDOFCONTENT
EOF
-print $fh $template;
+print $fh Encode::encode("UTF-8",$template);
close $fh;
my ( $url, $m ) = RT::Test->started_ok;
@@ -33,7 +30,7 @@ $m->submit_form(
button => 'Parse',
);
-$m->content_contains( '这是正文', 'content is parsed right' );
+$m->content_contains( Encode::decode("UTF-8",'这是正文'), 'content is parsed right' );
$m->submit_form(
form_name => 'TicketUpdate',
@@ -48,9 +45,9 @@ my ( $ticket_id ) = $m->content =~ /Ticket (\d+) created/;
my $ticket = RT::Ticket->new( RT->SystemUser );
$ticket->Load( $ticket_id );
-is( $ticket->Subject, '标题', 'subject in $ticket is right' );
+is( $ticket->Subject, Encode::decode("UTF-8",'标题'), 'subject in $ticket is right' );
$m->goto_ticket($ticket_id);
-$m->content_contains( '这是正文',
+$m->content_contains( Encode::decode("UTF-8",'这是正文'),
'content is right in ticket display page' );
diff --git a/rt/t/web/plugin-overlays.t b/rt/t/web/plugin-overlays.t
new file mode 100644
index 000000000..fec458964
--- /dev/null
+++ b/rt/t/web/plugin-overlays.t
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+BEGIN {
+ use Test::More;
+ plan skip_all => "Testing the rt-server init sequence in isolation requires Apache"
+ unless ($ENV{RT_TEST_WEB_HANDLER} || '') =~ /^apache/;
+}
+
+use JSON qw(from_json);
+
+use RT::Test
+ tests => undef,
+ plugins => ["Overlays"];
+
+my ($base, $m) = RT::Test->started_ok;
+
+# Check that the overlay was actually loaded
+$m->get_ok("$base/overlay_loaded");
+is $m->content, "yes", "Plugin's RT/User_Local.pm was loaded";
+
+# Check accessible is correct and doesn't need to be rebuilt from overlay
+$m->get_ok("$base/user_accessible");
+ok $m->content, "Received some content";
+
+my $info = from_json($m->content) || {};
+ok $info->{Comments}{public}, "User.Comments is marked public via overlay";
+
+undef $m;
+done_testing;
diff --git a/rt/t/web/query_builder.t b/rt/t/web/query_builder.t
index 13cd1b5d0..3589c381a 100644
--- a/rt/t/web/query_builder.t
+++ b/rt/t/web/query_builder.t
@@ -3,7 +3,6 @@ use warnings;
use HTTP::Request::Common;
use HTTP::Cookies;
use LWP;
-use Encode;
use RT::Test tests => 70;
my $cookie_jar = HTTP::Cookies->new;
diff --git a/rt/t/web/rest-non-ascii-subject.t b/rt/t/web/rest-non-ascii-subject.t
index 8b870a8b1..0d3e14dfb 100644
--- a/rt/t/web/rest-non-ascii-subject.t
+++ b/rt/t/web/rest-non-ascii-subject.t
@@ -3,8 +3,6 @@ use strict;
use warnings;
use RT::Test tests => 9;
-use Encode;
-# \x{XX} where XX is less than 255 is not treated as unicode code point
my $subject = Encode::decode('latin1', "Sujet accentu\x{e9}");
my $text = Encode::decode('latin1', "Contenu accentu\x{e9}");
@@ -32,8 +30,7 @@ Text: $text";
$m->post("$baseurl/REST/1.0/ticket/new", [
user => 'root',
pass => 'password',
-# error message from HTTP::Message: content must be bytes
- content => Encode::encode_utf8($content),
+ content => Encode::encode( "UTF-8", $content),
], Content_Type => 'form-data' );
my ($id) = $m->content =~ /Ticket (\d+) created/;
diff --git a/rt/t/web/sidebyside_layout.t b/rt/t/web/sidebyside_layout.t
new file mode 100644
index 000000000..88ea10cc5
--- /dev/null
+++ b/rt/t/web/sidebyside_layout.t
@@ -0,0 +1,45 @@
+use strict;
+use warnings;
+use RT::Test tests => 11;
+
+RT->Config->Set( UseSideBySideLayout => 0 );
+
+my $root = RT::Test->load_or_create_user( Name => 'root', );
+my ( $status, $msg ) = $root->SetPreferences(
+ $RT::System => {
+ %{ $root->Preferences($RT::System) || {} }, 'UseSideBySideLayout' => 1
+ }
+);
+ok( $status, 'use side by side layout for root' );
+
+my $user_a = RT::Test->load_or_create_user(
+ Name => 'user_a',
+ Password => 'password',
+);
+ok( $user_a->id, 'created user_a' );
+
+ok(
+ RT::Test->set_rights(
+ {
+ Principal => $user_a,
+ Right => ['CreateTicket']
+ },
+ ),
+ 'granted user_a the right of CreateTicket'
+);
+
+my ( $url, $m ) = RT::Test->started_ok;
+$m->login;
+$m->get_ok( $url . '/Ticket/Create.html?Queue=1', "root's ticket create page" );
+$m->content_like( qr/<body [^>]*class="[^>"]*\bsidebyside\b/,
+ 'found sidebyside css for root' );
+
+my $m_a = RT::Test::Web->new;
+ok $m_a->login( 'user_a', 'password' ), 'logged in as user_a';
+$m_a->get_ok( $url . '/Ticket/Create.html?Queue=1',
+ "user_a's ticket create page" );
+$m_a->content_unlike(
+ qr/<body [^>]*class="[^>"]*\bsidebyside\b/,
+ "didn't find sidebyside class for user_a"
+);
+
diff --git a/rt/t/web/ticket-create-utf8.t b/rt/t/web/ticket-create-utf8.t
index bebc57b51..107e41d71 100644
--- a/rt/t/web/ticket-create-utf8.t
+++ b/rt/t/web/ticket-create-utf8.t
@@ -4,8 +4,6 @@ use warnings;
use RT::Test tests => 43;
-use Encode;
-
my $ru_test = "\x{442}\x{435}\x{441}\x{442}";
my $ru_support = "\x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}";
diff --git a/rt/t/web/ticket_txn_subject.t b/rt/t/web/ticket_txn_subject.t
new file mode 100644
index 000000000..a43f05d96
--- /dev/null
+++ b/rt/t/web/ticket_txn_subject.t
@@ -0,0 +1,85 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my ($base, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+my @tickets;
+
+diag "create a ticket via the API";
+{
+ my $ticket = RT::Ticket->new( RT->SystemUser );
+ my ($id, $txn, $msg) = $ticket->Create(
+ Queue => 'General',
+ Subject => Encode::decode("UTF-8",'bad subject‽'),
+ );
+ ok $id, 'created a ticket #'. $id or diag "error: $msg";
+ is $ticket->Subject, Encode::decode("UTF-8",'bad subject‽'), 'correct subject';
+ push @tickets, $id;
+}
+
+diag "create a ticket via the web";
+{
+ $m->submit_form_ok({
+ form_name => "CreateTicketInQueue",
+ fields => { Queue => 1 },
+ }, 'create ticket in Queue');
+ $m->submit_form_ok({
+ with_fields => {
+ Subject => Encode::decode("UTF-8",'bad subject #2‽'),
+ },
+ }, 'create ticket');
+ $m->content_contains(Encode::decode("UTF-8",'bad subject #2‽'), 'correct subject');
+ push @tickets, 2;
+}
+
+diag "create a ticket via the web without a unicode subject";
+{
+ $m->submit_form_ok({
+ with_fields => { Queue => 1 },
+ }, 'create ticket in Queue');
+ $m->submit_form_ok({
+ with_fields => {
+ Subject => 'a fine subject #3',
+ },
+ }, 'create ticket');
+ $m->content_contains('a fine subject #3', 'correct subject');
+ push @tickets, 3;
+}
+
+for my $tid (@tickets) {
+ diag "ticket #$tid";
+ diag "add a reply which adds to the subject, but without an attachment";
+ {
+ $m->goto_ticket($tid);
+ $m->follow_link_ok({ id => 'page-actions-reply' }, "Actions -> Reply");
+ $m->submit_form_ok({
+ with_fields => {
+ UpdateSubject => Encode::decode("UTF-8",'bad subject‽ without attachment'),
+ UpdateContent => 'testing unicode txn subjects',
+ },
+ button => 'SubmitTicket',
+ }, 'submit reply');
+ $m->content_contains(Encode::decode("UTF-8",'bad subject‽ without attachment'), "found txn subject");
+ }
+
+ diag "add a reply which adds to the subject with an attachment";
+ {
+ $m->goto_ticket($tid);
+ $m->follow_link_ok({ id => 'page-actions-reply' }, "Actions -> Reply");
+ $m->submit_form_ok({
+ with_fields => {
+ UpdateSubject => Encode::decode("UTF-8",'bad subject‽ with attachment'),
+ UpdateContent => 'testing unicode txn subjects',
+ Attach => RT::Test::get_relocatable_file('bpslogo.png', '..', 'data'),
+ },
+ button => 'SubmitTicket',
+ }, 'submit reply');
+ $m->content_contains(Encode::decode("UTF-8",'bad subject‽ with attachment'), "found txn subject");
+ }
+}
+
+undef $m;
+done_testing;
diff --git a/rt/t/web/user_update.t b/rt/t/web/user_update.t
index c0e9e5264..54139d797 100644
--- a/rt/t/web/user_update.t
+++ b/rt/t/web/user_update.t
@@ -1,6 +1,5 @@
use strict;
use warnings;
-use utf8;
use RT::Test tests => undef;
my ( $url, $m ) = RT::Test->started_ok;
@@ -10,7 +9,7 @@ $m->follow_link_ok({text => 'About me'});
$m->submit_form_ok({ with_fields => { Lang => 'ja'} },
"Change to Japanese");
$m->text_contains("Lang changed from (no value) to 'ja'");
-$m->text_contains("実名", "Page content is japanese");
+$m->text_contains(Encode::decode("UTF-8","実名"), "Page content is japanese");
# we only changed one field, and it wasn't the default, so this feedback is
# spurious and annoying
@@ -22,7 +21,7 @@ $m->submit_form_ok({ with_fields => { Lang => 'en_us'} },
# This message shows up in Japanese
# $m->text_contains("Lang changed from 'ja' to 'en_us'");
-$m->text_contains("Langは「'ja'」から「'en_us'」に変更されました");
+$m->text_contains(Encode::decode("UTF-8","Langは「'ja'」から「'en_us'」に変更されました"));
$m->text_contains("Real Name", "Page content is english");
# Check for a lack of spurious updates
@@ -32,12 +31,11 @@ $m->content_lacks("That is already the current value");
$m->submit_form_ok({ with_fields => { Lang => 'ja'} },
"Back briefly to Japanese");
$m->text_contains("Lang changed from 'en_us' to 'ja'");
-$m->text_contains("実名", "Page content is japanese");
+$m->text_contains(Encode::decode("UTF-8","実名"), "Page content is japanese");
$m->submit_form_ok({ with_fields => { Lang => ''} },
"And set to the default");
-$m->text_contains("Langは「'ja'」から「(値なし)」に変更されました");
+$m->text_contains(Encode::decode("UTF-8","Langは「'ja'」から「(値なし)」に変更されました"));
$m->text_contains("Real Name", "Page content is english");
undef $m;
-
done_testing;