[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.1-298-g04a3409

Brian Duggan brian at bestpractical.com
Fri Jan 27 13:25:24 EST 2017


The branch, 4.4-trunk has been updated
       via  04a34091bd2b74ea7d5e2f21056fa91eaf0d10af (commit)
       via  84cb52cf6e3a48c8d9af5bbd4de15fc7fadddbb4 (commit)
       via  3a27d6c518296264410d47bcab7f6484a0f009f3 (commit)
      from  7b70c9faddb07dcc6d1eec634625e35038a4ee31 (commit)

Summary of changes:
 lib/RT/Ticket.pm      |  6 ++--
 t/customroles/merge.t | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+), 2 deletions(-)
 create mode 100644 t/customroles/merge.t

- Log -----------------------------------------------------------------
commit 3a27d6c518296264410d47bcab7f6484a0f009f3
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Dec 16 18:06:55 2016 +0000

    Add failing test for nonexistent role groups + merge
    
    See I#32490

diff --git a/t/customroles/merge.t b/t/customroles/merge.t
new file mode 100644
index 0000000..321de62
--- /dev/null
+++ b/t/customroles/merge.t
@@ -0,0 +1,88 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my $general = RT::Test->load_or_create_queue( Name => 'General' );
+
+my $linus = RT::Test->load_or_create_user( EmailAddress => 'linus at example.com' );
+my $blake = RT::Test->load_or_create_user( EmailAddress => 'blake at example.com' );
+my $williamson = RT::Test->load_or_create_user( EmailAddress => 'williamson at example.com' );
+
+diag 'create tickets' if $ENV{'TEST_VERBOSE'};
+my ($t1, $t2);
+{
+    $t1 = RT::Test->create_ticket( Queue => 'General', Subject => 'alpha' );
+    ok($t1->Id);
+    $t2 = RT::Test->create_ticket( Queue => 'General', Subject => 'beta' );
+    ok($t2->Id);
+}
+
+diag 'create a multi-member role' if $ENV{'TEST_VERBOSE'};
+my $multi;
+{
+    $multi = RT::CustomRole->new(RT->SystemUser);
+    my ($ok, $msg) = $multi->Create(
+        Name      => 'Multi-' . $$,
+        MaxValues => 0,
+    );
+    ok($ok, "created role: $msg");
+
+    ($ok, $msg) = $multi->AddToObject($general->id);
+    ok($ok, "added role to General: $msg");
+}
+
+diag 'create a single-member role' if $ENV{'TEST_VERBOSE'};
+my $single;
+{
+    $single = RT::CustomRole->new(RT->SystemUser);
+    my ($ok, $msg) = $single->Create(
+        Name      => 'Single-' . $$,
+        MaxValues => 1,
+    );
+    ok($ok, "created role: $msg");
+
+    ($ok, $msg) = $single->AddToObject($general->id);
+    ok($ok, "added role to General: $msg");
+}
+
+diag 'merge tickets [issues.bestpractical.com #32490]' if $ENV{'TEST_VERBOSE'};
+{
+    my ($ok, $msg) = $t2->MergeInto($t1->Id);
+    ok($ok, $msg);
+
+    is($t1->RoleAddresses($multi->GroupType), '', 'no multi members');
+    is($t1->RoleAddresses($single->GroupType), '', 'no single members');
+}
+
+diag 'create tickets specifying roles' if $ENV{'TEST_VERBOSE'};
+my ($t3, $t4);
+{
+    $t3 = RT::Test->create_ticket(
+        Queue => 'General',
+        Subject => 'gamma',
+        $multi->GroupType => [$linus->EmailAddress],
+        $single->GroupType => $linus,
+    );
+    ok($t3->Id);
+
+    $t4 = RT::Test->create_ticket(
+        Queue => 'General',
+        Subject => 'gamma',
+        $multi->GroupType => [$blake->EmailAddress, $williamson->EmailAddress],
+        $single->GroupType => $blake,
+    );
+    ok($t4->Id);
+}
+
+diag 'merge tickets' if $ENV{'TEST_VERBOSE'};
+{
+    my ($ok, $msg) = $t4->MergeInto($t3->Id);
+    ok($ok, $msg);
+
+    is($t3->RoleAddresses($multi->GroupType), (join ', ', sort $blake->EmailAddress, $linus->EmailAddress, $williamson->EmailAddress), 'merged all multi-member addresses');
+    is($t3->RoleAddresses($single->GroupType), $linus->EmailAddress, 'took single-member address from merged-into ticket')
+}
+
+done_testing;
+

commit 84cb52cf6e3a48c8d9af5bbd4de15fc7fadddbb4
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri Dec 16 18:21:06 2016 +0000

    Fix lazily-created custom role groups breaking ticket merge
    
    See test in previous commit
    
    Fixes: T#32490

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index ff9b8d2..984393f 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1825,8 +1825,10 @@ sub _MergeInto {
 
     # add all of this ticket's watchers to that ticket.
     for my $role ($self->Roles) {
-        next if $self->RoleGroup($role)->SingleMemberRoleGroup;
-        my $people = $self->RoleGroup($role)->MembersObj;
+        my $group = $self->RoleGroup($role);
+        next unless $group->Id; # e.g. lazily-created custom role groups
+        next if $group->SingleMemberRoleGroup;
+        my $people = $group->MembersObj;
         while ( my $watcher = $people->Next ) {
             my ($val, $msg) =  $MergeInto->AddRoleMember(
                 Type              => $role,

commit 04a34091bd2b74ea7d5e2f21056fa91eaf0d10af
Merge: 7b70c9f 84cb52c
Author: Brian C. Duggan <brian at bestpractical.com>
Date:   Fri Jan 27 13:24:57 2017 -0500

    Merge branch '4.4/customrole-merge' into 4.4-trunk


-----------------------------------------------------------------------


More information about the rt-commit mailing list