[Bps-public-commit] rt-extension-rest2 branch, update-custom-roles-on-correspond-and-comment, updated. 1.09-8-ge079881
Dianne Skoll
dianne at bestpractical.com
Mon Dec 14 09:28:31 EST 2020
The branch, update-custom-roles-on-correspond-and-comment has been updated
via e0798810bf8bf20f1d11e69d1d825be4f3f9e713 (commit)
from 95f2e4395dfdf7f860674cad8b88bf0b68e5a63c (commit)
Summary of changes:
lib/RT/Extension/REST2.pm | 7 +++----
lib/RT/Extension/REST2/Util.pm | 12 ++----------
xt/ticket-correspond-update-customroles.t | 6 +++---
3 files changed, 8 insertions(+), 17 deletions(-)
- Log -----------------------------------------------------------------
commit e0798810bf8bf20f1d11e69d1d825be4f3f9e713
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Mon Dec 14 09:28:04 2020 -0500
Always set multi-member custom roles to supplied address(es) rather than adding a watcher if a single address is given.
diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index 1538bda..1cd1039 100644
--- a/lib/RT/Extension/REST2.pm
+++ b/lib/RT/Extension/REST2.pm
@@ -277,10 +277,9 @@ For a single-value custom role, the value must be a string representing an
email address; the custom role is set to that address.
For a multi-value custom role, the value can be a string representing
-an email address, in which case the address is added to the members of
-the custom role. Alternatively, it can be an array of email addresses,
-in which case the members of the custom role are set to those email
-addresses.
+an email address or can be an array of email addresses; in either
+case, the members of the custom role are set to the email address or
+addresses supplied.
=back
diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
index 30d58f7..fd8a6ce 100644
--- a/lib/RT/Extension/REST2/Util.pm
+++ b/lib/RT/Extension/REST2/Util.pm
@@ -447,17 +447,9 @@ sub update_custom_role {
}
}
- # Must be a multi-value custom role. If $val is a scalar,
- # add the watcher. If $val is an array, replace existing watchers
- # with $val
+ # Convert a string value to a single-element array
if (!ref($val)) {
- my ($ok, $msg) = $ticket->AddWatcher(Type => $role_type,
- User => $val);
- if ($ok) {
- return "Added $val to '$rolename'";
- } else {
- return $msg || "Unable to add $val to '$rolename'";
- }
+ $val = [ $val ];
}
# Multi-value custom role and we should have been given an array
diff --git a/xt/ticket-correspond-update-customroles.t b/xt/ticket-correspond-update-customroles.t
index 57ef77c..a612473 100644
--- a/xt/ticket-correspond-update-customroles.t
+++ b/xt/ticket-correspond-update-customroles.t
@@ -117,7 +117,7 @@ my ($ticket_url, $ticket_id);
# Because CustomRoles are set in an unpredictable order, sort the
# responses so we have a predictable order.
@$content = sort { $a cmp $b } (@$content);
- cmp_deeply($content, ["Added quux\@cabbage.example to 'Multi Member'", re(qr/Correspondence added|Message recorded/), "Set 'Single Member' to foo\@bar.example"]);
+ cmp_deeply($content, [re(qr/Correspondence added|Message recorded/), "Set 'Single Member' to foo\@bar.example", "Updated 'RT::CustomRole-2'"]);
like($res->header('Location'), qr{$rest_base_path/transaction/\d+$});
$res = $mech->get($res->header('Location'),
'Authorization' => $auth,
@@ -162,7 +162,7 @@ my ($ticket_url, $ticket_id);
is($ticket->RoleAddresses("RT::CustomRole-$single_id"), 'foo-new at bar.example',
"Single Member role set correctly");
- is($ticket->RoleAddresses("RT::CustomRole-$multi_id"), 'quux-new at cabbage.example, quux at cabbage.example',
+ is($ticket->RoleAddresses("RT::CustomRole-$multi_id"), 'quux-new at cabbage.example',
"Multi Member role updated correctly");
# Supply an array for multi-member role
@@ -198,7 +198,7 @@ my ($ticket_url, $ticket_id);
is($ticket->RoleAddresses("RT::CustomRole-$single_id"), 'foo-new at bar.example',
"Single Member role unchanged");
- is($ticket->RoleAddresses("RT::CustomRole-$multi_id"), 'abacus at example.com, quux-new at cabbage.example',
+ is($ticket->RoleAddresses("RT::CustomRole-$multi_id"), 'abacus at example.com',
"Multi Member role unchanged");
# Supply an array for single-member role
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list