summaryrefslogtreecommitdiff
path: root/rt/t
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2020-05-18 17:02:39 -0700
committerIvan Kohler <ivan@freeside.biz>2020-05-18 17:02:39 -0700
commit187086c479a09629b7d180eec513fb7657f4e291 (patch)
tree3e6236990c91d942105b6fdaf8de8eabdff85186 /rt/t
parent4639e25a658d9a0bf295415642fae8e8cdad846a (diff)
rt 4.2.15
Diffstat (limited to 'rt/t')
-rw-r--r--rt/t/customfields/api.t30
-rw-r--r--rt/t/shredder/03plugin_users.t56
-rw-r--r--rt/t/web/reminder-permissions.t4
-rw-r--r--rt/t/web/reminders.t6
-rw-r--r--rt/t/web/ticket_modify_people.t35
5 files changed, 98 insertions, 33 deletions
diff --git a/rt/t/customfields/api.t b/rt/t/customfields/api.t
index a50ca77..f4551b3 100644
--- a/rt/t/customfields/api.t
+++ b/rt/t/customfields/api.t
@@ -2,7 +2,7 @@
use strict;
use warnings FATAL => 'all';
-use RT::Test nodata => 1, tests => 145;
+use RT::Test nodata => 1, tests => undef;
use Test::Warn;
# Before we get going, ditch all object_cfs; this will remove
@@ -223,6 +223,32 @@ warning_like {
is($load->Id, $global_cf3->Id, "Loading by name gets non-disabled first, even with order swapped");
}
+{
+ my $cf = RT::Test->load_or_create_custom_field(
+ Name => 'HasEntry cache',
+ Type => 'FreeformSingle',
+ Queue => 0,
+ );
+
+ my ( $ret, $msg ) = $ticket->AddCustomFieldValue( Field => $cf, Value => 'foo' );
+ ok( $ret, $msg );
+ is( $ticket->FirstCustomFieldValue( $cf ), 'foo', 'value is foo' );
+ my $ocfvs = $ticket->CustomFieldValues( $cf );
+ ok( $ocfvs->HasEntry( 'foo' ), 'foo is cached in HasEntry' );
+
+ ( $ret, $msg ) = $ticket->AddCustomFieldValue( Field => $cf, Value => 'bar' );
+ ok( $ret, $msg );
+ is( $ticket->FirstCustomFieldValue( $cf ), 'bar', 'value is bar' );
+ ok( !$ocfvs->HasEntry( 'foo' ), 'foo is not cached in HasEntry' );
+ ok( $ocfvs->HasEntry( 'bar' ), 'bar is cached in HasEntry' );
+
+ ( $ret, $msg ) = $ticket->AddCustomFieldValue( Field => $cf, Value => 'foo' );
+ ok( $ret, $msg );
+ is( $ticket->FirstCustomFieldValue( $cf ), 'foo', 'value is foo' );
+ ok( $ocfvs->HasEntry( 'foo' ), 'foo is cached in HasEntry' );
+ ok( !$ocfvs->HasEntry( 'bar' ), 'bar is not cached in HasEntry' );
+}
+
#SKIP: {
# skip "TODO: should we add CF values to objects via CF Name?", 48;
# names are not unique
@@ -230,4 +256,4 @@ warning_like {
# $test_add_delete_cycle->( sub { return $_[0]->Name } );
#}
-
+done_testing;
diff --git a/rt/t/shredder/03plugin_users.t b/rt/t/shredder/03plugin_users.t
index 8f0fc2c..75a9201 100644
--- a/rt/t/shredder/03plugin_users.t
+++ b/rt/t/shredder/03plugin_users.t
@@ -3,7 +3,7 @@ use strict;
use warnings;
use Test::Deep;
-use RT::Test::Shredder tests => 21;
+use RT::Test::Shredder tests => undef;
my $test = "RT::Test::Shredder";
my @ARGS = sort qw(limit status name member_of not_member_of email replace_relations no_tickets no_ticket_transactions);
@@ -87,3 +87,57 @@ $test->create_savepoint('clean');
$shredder->Wipeout( Object => $userA );
}
cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
+
+{ # Same as previous test, but pass Objects to PutObjects in the same form as the web interface
+ my ($uidA, $uidB, $msg);
+ my $userA = RT::User->new( RT->SystemUser );
+ ($uidA, $msg) = $userA->Create( Name => 'userA', Privileged => 1, Disabled => 0 );
+ ok( $uidA, "created user A" ) or diag "error: $msg";
+
+ my $userB = RT::User->new( RT->SystemUser );
+ ($uidB, $msg) = $userB->Create( Name => 'userB', Privileged => 1, Disabled => 0 );
+ ok( $uidB, "created user B" ) or diag "error: $msg";
+
+ my ($tid, $trid);
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new($userB) );
+ ($tid, $trid, $msg) = $ticket->Create( Subject => 'UserB Ticket', Queue => 1 );
+ ok( $tid, "created new ticket") or diag "error: $msg";
+ $ticket->ApplyTransactionBatch;
+
+ my $transaction = RT::Transaction->new( RT->SystemUser );
+ $transaction->Load($trid);
+ is ( $transaction->Creator, $uidB, "ticket creator is user B" );
+
+ my $plugin = RT::Shredder::Plugin::Users->new;
+ isa_ok($plugin, 'RT::Shredder::Plugin::Users');
+
+ my $status;
+ ($status, $msg) = $plugin->TestArgs( status => 'any', name => 'userB', replace_relations => $uidA );
+ ok($status, "plugin arguments are ok") or diag "error: $msg";
+
+ my $shredder = $test->shredder_new();
+
+ my @objs;
+ ($status, @objs) = $plugin->Run;
+ ok($status, "executed plugin successfully") or diag "error: @objs";
+
+ # Same form as param coming in via the web interface
+ $shredder->PutObjects( Objects => ['RT::User-userB'] );
+
+ ($status, $msg) = $plugin->SetResolvers( Shredder => $shredder );
+ ok($status, "set conflicts resolver") or diag "error: $msg";
+
+ $shredder->WipeoutAll;
+
+ $ticket->Load( $tid );
+ is($ticket->id, $tid, 'loaded ticket');
+
+ $transaction->Load($trid);
+ is ( $transaction->Creator, $uidA, "ticket creator is now user A" );
+
+ $shredder->Wipeout( Object => $ticket );
+ $shredder->Wipeout( Object => $userA );
+}
+cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
+
+done_testing();
diff --git a/rt/t/web/reminder-permissions.t b/rt/t/web/reminder-permissions.t
index dd859cd..6f20497 100644
--- a/rt/t/web/reminder-permissions.t
+++ b/rt/t/web/reminder-permissions.t
@@ -90,7 +90,7 @@ qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"
'complete user_a reminder' );
$m_a->follow_link_ok( { id => 'page-reminders' } );
- $m_a->title_is( "Reminders for ticket #" . $ticket->id );
+ $m_a->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m_a->content_contains( 'root reminder', 'can see root reminder' );
$m_a->content_contains( 'user_a reminder', 'can see user_a reminder' );
$m_a->content_lacks( 'New reminder:', 'can not create a new reminder' );
@@ -126,7 +126,7 @@ qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"
'created user_a from display reminder' );
$m_a->follow_link_ok( { id => 'page-reminders' } );
- $m_a->title_is( "Reminders for ticket #" . $ticket->id );
+ $m_a->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m_a->content_contains( 'New reminder:', 'can create a new reminder' );
$m_a->content_like(
qr!<input[^/]+name="Complete-Reminder-$root_reminder_id"[^/]+disabled="disabled"!,
diff --git a/rt/t/web/reminders.t b/rt/t/web/reminders.t
index 98a8d69..e1eb46d 100644
--- a/rt/t/web/reminders.t
+++ b/rt/t/web/reminders.t
@@ -17,7 +17,7 @@ $m->content_unlike(qr{Check box to complete}, "we don't display this text when t
$m->content_unlike(qr{<th[^>]*>Reminders?</th>}, "no reminder titlebar");
$m->follow_link_ok({id => 'page-reminders'});
-$m->title_is("Reminders for ticket #" . $ticket->id);
+$m->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m->text_contains('New reminder:', 'can create a new reminder');
$m->content_unlike(qr{Check box to complete}, "we don't display this text when there are no reminders");
$m->content_unlike(qr{<th[^>]*>Reminders?</th>}, "no reminder titlebar");
@@ -63,7 +63,7 @@ $m->content_like(qr{<th[^>]*>Reminders?</th>}, "now we have a reminder titlebar"
$m->text_contains("baby's first reminder", "display the reminder's subject");
$m->follow_link_ok({id => 'page-reminders'});
-$m->title_is("Reminders for ticket #" . $ticket->id);
+$m->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m->form_name('UpdateReminders');
$m->field("Reminder-Subject-$reminder_id" => "changed the subject");
$m->submit;
@@ -90,7 +90,7 @@ $m->content_unlike(qr{<th[^>]*>Reminders?</th>}, "no reminder titlebar");
$m->content_unlike(qr{baby's first reminder}, "we don't display resolved reminders");
$m->follow_link_ok({id => 'page-reminders'});
-$m->title_is("Reminders for ticket #" . $ticket->id);
+$m->title_is("Reminders for ticket #" . $ticket->id . ": " . $ticket->Subject);
$m->text_contains('New reminder:', 'can create a new reminder');
$m->text_contains('Check box to complete', "we DO display this text when there are reminders");
$m->content_contains("changed the subject", "display the resolved reminder's subject");
diff --git a/rt/t/web/ticket_modify_people.t b/rt/t/web/ticket_modify_people.t
index cefbf91..f4821a5 100644
--- a/rt/t/web/ticket_modify_people.t
+++ b/rt/t/web/ticket_modify_people.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use RT::Test tests => 25;
+use RT::Test tests => undef;
my $root = RT::Test->load_or_create_user( Name => 'root' );
my $group_foo = RT::Group->new($RT::SystemUser);
@@ -36,11 +36,11 @@ ok( $m->login( 'user', 'password' ), 'logged in' );
$m->get_ok( $url . "/Ticket/ModifyPeople.html?id=" . $ticket->id );
ok(
- !$m->find_link(
- text => 'Enoch Root',
- url_regex => qr!/Admin/Users/Modify\.html!,
+ $m->find_link(
+ text => 'root (Enoch Root)',
+ url_regex => qr!/User/Summary\.html!,
),
- 'no link to modify user'
+ 'contains link to user summary page'
);
$m->content_contains('Enoch Root', 'still has the user name' );
@@ -54,24 +54,6 @@ ok(
$m->content_contains('group_foo', 'still has the group name' );
-ok( RT::Test->add_rights( { Principal => $user, Right => ['AdminUsers'] }, ),
- 'added AdminUsers right' );
-$m->reload;
-ok(
- !$m->find_link(
- text => 'Enoch Root',
- url_regex => qr!/Admin/Users/Modify\.html!,
- ),
- 'still no link to modify user'
-);
-ok(
- !$m->find_link(
- text => 'group_foo',
- url_regex => qr!/Admin/Groups/Modify\.html!,
- ),
- 'still no link to modify group'
-);
-
ok(
RT::Test->add_rights( { Principal => $user, Right => ['ShowConfigTab'] }, ),
'added ShowConfigTab right',
@@ -81,9 +63,9 @@ $m->reload;
ok(
$m->find_link(
text => 'root (Enoch Root)',
- url_regex => qr!/Admin/Users/Modify\.html!,
+ url_regex => qr!/User/Summary\.html!,
),
- 'got link to modify user'
+ 'still contains link to user summary page'
);
ok(
@@ -119,5 +101,8 @@ $m->submit_form_ok({
my $foo = RT::Test->load_or_create_user( EmailAddress => 'foo@example.com' );
is $foo->RealName, "Foo Bar", "RealName matches";
+undef $m;
+done_testing;
+
# TODO test Add|Delete people