[Bps-public-commit] rt-extension-rest2 branch, update-custom-roles-on-correspond-and-comment, repushed

Jim Brandt jbrandt at bestpractical.com
Mon Jan 25 15:17:23 EST 2021


The branch update-custom-roles-on-correspond-and-comment was deleted and repushed:
       was 3fa8e151b05ceac516c23d33d834ad0e1e9666e2
       now d20d5605523b6ea76c3a04d4833ab7f5ba4975d0

1:  e6c06b1 ! 1:  d3b5534 Move update_role_members to Util for general use
    @@ -1,6 +1,13 @@
     Author: Dianne Skoll <dianne at bestpractical.com>
     
    -    Move update_role_members Util.pm; implement fix_custom_role_ids
    +    Move update_role_members to Util for general use
    +    
    +    Like custom field updates previously, custom role
    +    updates can happen in multiple places. Move
    +    update_role_members so they can all call the same code.
    +    
    +    Also implement fix_custom_role_ids in Util.pm to standardize
    +    different types of input parameters for custom roles.
     
     diff --git a/lib/RT/Extension/REST2/Resource/Record/Writable.pm b/lib/RT/Extension/REST2/Resource/Record/Writable.pm
     --- a/lib/RT/Extension/REST2/Resource/Record/Writable.pm
2:  4350694 = 2:  5054bf0 Allow updating of custom roles on ticket comment/correspond
3:  287a7c8 ! 3:  608e4f7 Document CustomFields, TxnCustomFields and CustomRoles data members
    @@ -37,4 +37,16 @@
      =back
      
      =head3 Add Attachments
    +@@
    +         -d '{ "Content": "Testing a comment", "ContentType": "text/plain", "CustomFields": {"Severity": "High"} }'
    +         'https://myrt.com/REST/2.0/ticket/6/comment'
    + 
    ++    # Comment on a ticket with custom role update
    ++    curl -X POST -H "Content-Type: application/json" -u 'root:password'
    ++        -d '{ "Content": "Testing a comment", "ContentType": "text/plain", "CustomRoles": {"Manager": "manager at example.com"} }'
    ++        'https://myrt.com/REST/2.0/ticket/6/comment'
    ++
    + =head3 Transactions
    + 
    +     GET /transactions?query=<JSON>
     
4:  3fa8e15 ! 4:  d20d560 Add unit test for updating custom roles on ticket comment/correspond
    @@ -14,10 +14,10 @@
              );
              return $u;
     
    -diff --git a/ticket-correspond-update-customroles.t b/ticket-correspond-update-customroles.t
    +diff --git a/xt/ticket-correspond-customroles.t b/xt/ticket-correspond-customroles.t
     new file mode 100644
     --- /dev/null
    -+++ b/ticket-correspond-update-customroles.t
    ++++ b/xt/ticket-correspond-customroles.t
     @@
     +use strict;
     +use warnings;
    @@ -54,12 +54,6 @@
     +($ok, $msg) = $multi->AddToObject($queue->id);
     +ok($ok, $msg);
     +
    -+#for my $email (qw/multi at example.com test at localhost multi2 at example.com single2 at example.com/) {
    -+#    my $user = RT::User->new(RT->SystemUser);
    -+#    my ($ok, $msg) = $user->Create(Name => $email, EmailAddress => $email);
    -+#    ok($ok, $msg);
    -+#}
    -+
     +$user->PrincipalObj->GrantRight( Right => $_ )
     +    for qw/CreateTicket ShowTicket ModifyTicket OwnTicket AdminUsers SeeGroup SeeQueue/;
     +
    @@ -103,7 +97,7 @@
     +                                     Created Due Priority EffectiveId);
     +}
     +
    -+# Ticket Reply
    ++diag "Correspond with custom roles";
     +{
     +    $user->PrincipalObj->GrantRight( Right => 'ReplyToTicket' );
     +
    @@ -166,8 +160,24 @@
     +       "Single Member role set correctly");
     +    is($ticket->RoleAddresses("RT::CustomRole-$multi_id"), 'quux at cabbage.example',
     +       "Multi Member role set correctly");
    -+
    -+    # Update again (this time as a comment)
    ++}
    ++
    ++diag "Comment with custom roles";
    ++{
    ++    $user->PrincipalObj->GrantRight( Right => 'CommentOnTicket' );
    ++
    ++    my $res = $mech->get($ticket_url,
    ++        'Authorization' => $auth,
    ++    );
    ++    is($res->code, 200);
    ++    my $content = $mech->json_response;
    ++
    ++    my ($hypermedia) = grep { $_->{ref} eq 'comment' } @{ $content->{_hyperlinks} };
    ++    ok($hypermedia, 'got comment hypermedia');
    ++    like($hypermedia->{_url}, qr[$rest_base_path/ticket/$ticket_id/comment$]);
    ++
    ++    my $comment_url = $mech->url_for_hypermedia('comment');
    ++
     +    $res = $mech->post_json($comment_url,
     +        {
     +            Content => 'Hello from hypermedia!',
    @@ -180,6 +190,10 @@
     +        'Authorization' => $auth,
     +    );
     +    is($res->code, 201);
    ++
    ++    # Load the ticket and check the custom roles
    ++    my $ticket = RT::Ticket->new($user);
    ++    $ticket->Load($ticket_id);
     +
     +    is($ticket->RoleAddresses("RT::CustomRole-$single_id"), 'foo-new at bar.example',
     +       "Single Member role set correctly");
    @@ -187,7 +201,7 @@
     +       "Multi Member role updated correctly");
     +
     +    # Supply an array for multi-member role
    -+    $res = $mech->post_json($correspond_url,
    ++    $res = $mech->post_json($comment_url,
     +        {
     +            Content => 'Hello from hypermedia!',
     +            ContentType => 'text/plain',
    @@ -205,7 +219,7 @@
     +       "Multi Member role set correctly");
     +
     +    # Add an existing user to multi-member role
    -+    $res = $mech->post_json($correspond_url,
    ++    $res = $mech->post_json($comment_url,
     +        {
     +            Content => 'Hello from hypermedia!',
     +            ContentType => 'text/plain',
    @@ -223,7 +237,7 @@
     +       "Multi Member role unchanged");
     +
     +    # Supply an array for single-member role
    -+    $res = $mech->post_json($correspond_url,
    ++    $res = $mech->post_json($comment_url,
     +        {
     +            Content => 'Hello from hypermedia!',
     +            ContentType => 'text/plain',
    @@ -235,12 +249,12 @@
     +    );
     +    is($res->code, 201);
     +    $content = $mech->json_response;
    -+    cmp_deeply($content, ['Correspondence added', 'Single Member changed from foo-new at bar.example to abacus at example.com'], "Got expected respose");
    ++    cmp_deeply($content, ['Comments added', 'Single Member changed from foo-new at bar.example to abacus at example.com'], "Got expected respose");
     +    is($ticket->RoleAddresses("RT::CustomRole-$single_id"), 'abacus at example.com',
     +       "Single Member role changed to first member of array");
     +
     +    # Try using a username instead of password
    -+    $res = $mech->post_json($correspond_url,
    ++    $res = $mech->post_json($comment_url,
     +        {
     +            Content => 'Hello from hypermedia!',
     +            ContentType => 'text/plain',
    @@ -252,7 +266,7 @@
     +    );
     +    is($res->code, 201);
     +    $content = $mech->json_response;
    -+    cmp_deeply($content, ['Correspondence added', 'Single Member changed from abacus at example.com to test'], "Got expected respose");
    ++    cmp_deeply($content, ['Comments added', 'Single Member changed from abacus at example.com to test'], "Got expected respose");
     +    is($ticket->RoleAddresses("RT::CustomRole-$single_id"), 'test at rt.example',
     +       "Single Member role changed");
     +}



More information about the Bps-public-commit mailing list