[Rt-commit] rt branch, 4.4/forbid-merging-reminders, created. rt-4.4.2-28-g8c2ffab
Maureen Mirville
maureen at bestpractical.com
Fri Aug 11 17:13:15 EDT 2017
The branch, 4.4/forbid-merging-reminders has been created
at 8c2ffab7059a48dce3ea46b735610a71f60fb404 (commit)
- Log -----------------------------------------------------------------
commit 1d4455db9055733ed0478308f24c2c86a0167194
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date: Thu Aug 10 11:09:05 2017 -0400
Only tickets can be merged
Each ticket has a type property. Only tickets with the type,
'ticket', can be merged. For example, 'reminder' tickets
cannot be merged.
Fixes I#32700
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 0f073c3..6cd8aff 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1881,6 +1881,12 @@ sub MergeInto {
if ( $MergeInto->Id == $self->Id ) {
return ( 0, $self->loc("Can't merge a ticket into itself") );
}
+
+ # Only tickets can be merged
+ unless ($MergeInto->Type eq 'ticket'){
+ my $id_num = $MergeInto->Id;
+ return(0, $self->loc("Id $id_num is not a ticket. Only tickets can be merged."));
+ };
# Make sure the current user can modify the new ticket.
unless ( $MergeInto->CurrentUserHasRight('ModifyTicket') ) {
commit 8c2ffab7059a48dce3ea46b735610a71f60fb404
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date: Thu Aug 10 11:17:03 2017 -0400
Tests for merging tickets
Tests added to verify that tickets can only merge into tickets
with the property type, 'ticket' (other types cannot be merged).
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 6cd8aff..9d1e698 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1880,8 +1880,8 @@ sub MergeInto {
# Can't merge into yourself
if ( $MergeInto->Id == $self->Id ) {
return ( 0, $self->loc("Can't merge a ticket into itself") );
- }
-
+ }
+
# Only tickets can be merged
unless ($MergeInto->Type eq 'ticket'){
my $id_num = $MergeInto->Id;
diff --git a/t/ticket/merge.t b/t/ticket/merge.t
index 99c723b..13e5959 100644
--- a/t/ticket/merge.t
+++ b/t/ticket/merge.t
@@ -4,7 +4,7 @@ use warnings;
use RT;
-use RT::Test tests => '44';
+use RT::Test;
# validate that when merging two tickets, the comments from both tickets
@@ -177,3 +177,36 @@ ok $user && $user->id, 'loaded or created user';
is $from_history, $expected, "history is correct";
}
}
+
+# forbid merging tickets into non-ticket types
+{
+
+ # create two tickets
+ my $ticket_1 = RT::Test->create_ticket(
+ Queue => 'General',
+ Subject => 'test ticket 1'
+ );
+ my $ticket_2 = RT::Test->create_ticket(
+ Queue => 'General',
+ Subject => 'test ticket 2'
+ );
+
+ # create a reminder on ticket_1
+ my ($reminder, $add_id) = $ticket_1->Reminders->Add(
+ Subject => 'Test Reminder',
+ Owner => 'root',
+ );
+
+ # verify reminder was created
+ my $reminders = $ticket_1->Reminders->Collection;
+ ok($reminders, 'Loading reminders for this ticket');
+ my $found = 0;
+ $reminder = $reminders->First;
+ $found = 1 if ( $reminder->Subject =~ m/Test Reminder/ );
+ is($found, 1, 'Reminder successfully added');
+
+ # verify ticket cannot be merged into non-ticket type
+ my($status, $msg) = $ticket_1->MergeInto($reminder);
+ ok(!$status, 'Only tickets can be merged');
+}
+done_testing();
-----------------------------------------------------------------------
More information about the rt-commit
mailing list