[Bps-public-commit] rt-extension-rest2 branch master updated. 1.14-5-g8d2ec27

BPS Git Server git at git.bestpractical.com
Mon Oct 18 17:41:41 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-rest2".

The branch, master has been updated
       via  8d2ec27e8aa246914fc3a210245b5b8d289e7f1f (commit)
       via  3422afb611a7059e71ae51534d615c14f47f105d (commit)
       via  7dcc6dc3ed2c7b959f0f2c5b25739caf0954bd01 (commit)
       via  453caf05981d2b5cb9b9184b496c8b6c3bde1204 (commit)
       via  b66532d2b6d3119f6f8e54aa0f4dc502f1777939 (commit)
      from  6bb60232b616f34b8f586c07fb747295b01c9647 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8d2ec27e8aa246914fc3a210245b5b8d289e7f1f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Oct 18 13:28:08 2021 -0400

    Release version 1.15

diff --git a/Changes b/Changes
index 2f7ddd3..8439331 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for RT-Extension-REST2
 
+1.15 2021-10-18
+ - Support custom roles by name on ticket update
+ - Add RT Version section
+
 1.14 2021-08-13
  - Support custom roles by name on ticket create
  - Skip invalid custom fields on create/update
diff --git a/META.yml b/META.yml
index ee908d0..0eca5f4 100644
--- a/META.yml
+++ b/META.yml
@@ -43,7 +43,7 @@ requires:
   perl: 5.10.1
 resources:
   license: http://opensource.org/licenses/gpl-license.php
-version: '1.14'
+version: '1.15'
 x_module_install_rtx_version: '0.42'
 x_requires_rt: 4.2.4
 x_rt_too_new: 5.0.0
diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index 9c52005..5e0c8fc 100644
--- a/lib/RT/Extension/REST2.pm
+++ b/lib/RT/Extension/REST2.pm
@@ -4,7 +4,7 @@ use 5.010001;
 
 package RT::Extension::REST2;
 
-our $VERSION = '1.14';
+our $VERSION = '1.15';
 our $REST_PATH = '/REST/2.0';
 
 use Plack::Builder;

commit 3422afb611a7059e71ae51534d615c14f47f105d
Merge: 6bb6023 7dcc6dc
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Oct 18 13:20:02 2021 -0400

    Merge branch 'custom-roles-on-update'


commit 7dcc6dc3ed2c7b959f0f2c5b25739caf0954bd01
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon Oct 18 13:06:47 2021 -0400

    Add RT Version section to docs

diff --git a/README b/README
index 0e7dbc7..446c50d 100644
--- a/README
+++ b/README
@@ -1,6 +1,12 @@
 NAME
     RT::Extension::REST2 - Adds a modern REST API to RT under /REST/2.0/
 
+RT VERSION
+    Works with RT 4.4.
+
+    REST2 is core in RT 5.0.0 and later, so you do not need this extension
+    for those versions.
+
 INSTALLATION
     perl Makefile.PL
     make
diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index 6ad6ac7..9c52005 100644
--- a/lib/RT/Extension/REST2.pm
+++ b/lib/RT/Extension/REST2.pm
@@ -16,6 +16,13 @@ use RT::Extension::REST2::Dispatcher;
 
 RT::Extension::REST2 - Adds a modern REST API to RT under /REST/2.0/
 
+=head1 RT VERSION
+
+Works with RT 4.4.
+
+REST2 is core in RT 5.0.0 and later, so you do not need this extension
+for those versions.
+
 =head1 INSTALLATION
 
 =over

commit 453caf05981d2b5cb9b9184b496c8b6c3bde1204
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 16 02:38:07 2021 +0800

    Add tests for custom roles on ticket update

diff --git a/xt/ticket-customroles.t b/xt/ticket-customroles.t
index 51cf4f6..8d9701b 100644
--- a/xt/ticket-customroles.t
+++ b/xt/ticket-customroles.t
@@ -309,6 +309,50 @@ diag 'Create and view ticket with custom roles by name';
             _url => re(qr{$rest_base_path/user/Nobody$}),
         }, 'Single Member has changed to Nobody');
     }
+
+    for my $identifier ($user->id, $user->Name) {
+        $payload = {
+            CustomRoles => { 'Single Member' => $identifier },
+        };
+
+        $res = $mech->put_json($ticket_url,
+            $payload,
+            'Authorization' => $auth,
+        );
+        is_deeply($mech->json_response, ["Single Member changed from Nobody to test"], "updated Single Member with identifier $identifier");
+
+        $res = $mech->get($ticket_url,
+            'Authorization' => $auth,
+        );
+        is($res->code, 200);
+
+        cmp_deeply($mech->json_response->{$single->GroupType}, {
+            type => 'user',
+            id   => 'test',
+            _url => re(qr{$rest_base_path/user/test$}),
+        }, 'Single Member has changed to test');
+
+        $payload = {
+            CustomRoles => { 'Single Member' => 'Nobody' },
+        };
+
+        $res = $mech->put_json($ticket_url,
+            $payload,
+            'Authorization' => $auth,
+        );
+        is_deeply($mech->json_response, ["Single Member changed from test to Nobody"], 'updated Single Member');
+
+        $res = $mech->get($ticket_url,
+            'Authorization' => $auth,
+        );
+        is($res->code, 200);
+
+        cmp_deeply($mech->json_response->{$single->GroupType}, {
+            type => 'user',
+            id   => 'Nobody',
+            _url => re(qr{$rest_base_path/user/Nobody$}),
+        }, 'Single Member has changed to Nobody');
+    }
 }
 
 # Modify multi-member roles
@@ -449,6 +493,32 @@ diag 'Create and view ticket with custom roles by name';
             _url => re(qr{$rest_base_path/user/multi\@example\.com$}),
         }), "preserved two Multi Members when $name");
     }
+
+    $payload = { CustomRoles => { 'Multi Member' => [ 'test at localhost', 'multi at example.com' ] }, };
+    $res     = $mech->put_json( $ticket_url, $payload, 'Authorization' => $auth, );
+    is_deeply(
+        $mech->json_response,
+        [   'Added test at localhost as Multi Member for this ticket',
+            'multi2 at example.com is no longer Multi Member for this ticket'
+        ],
+        "updated ticket watchers"
+    );
+    $res = $mech->get( $ticket_url, 'Authorization' => $auth, );
+    is( $res->code, 200 );
+    $content = $mech->json_response;
+    cmp_deeply(
+        $content->{ $multi->GroupType },
+        bag({   type => 'user',
+                id   => 'test at localhost',
+                _url => re(qr{$rest_base_path/user/test\@localhost$}),
+            },
+            {   type => 'user',
+                id   => 'multi at example.com',
+                _url => re(qr{$rest_base_path/user/multi\@example\.com$}),
+            }
+        ),
+        'two Multi Members'
+    );
 }
 
 # groups as members

commit b66532d2b6d3119f6f8e54aa0f4dc502f1777939
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 16 02:27:43 2021 +0800

    Support custom roles by name on ticket update
    
    We previously supported custom roles on ticket update using syntax like
    RT::CustomRole-2. This commit adds support for setting custom roles by
    name, using the same syntax as comment/correspond.
    
    With this, now we have consistent API on create, update and
    comment/correspond.

diff --git a/lib/RT/Extension/REST2/Resource/Record/Writable.pm b/lib/RT/Extension/REST2/Resource/Record/Writable.pm
index aa8d8a4..f96b7c8 100644
--- a/lib/RT/Extension/REST2/Resource/Record/Writable.pm
+++ b/lib/RT/Extension/REST2/Resource/Record/Writable.pm
@@ -119,6 +119,12 @@ sub update_record {
     my $self = shift;
     my $data = shift;
 
+    # update_role_members wants custom role IDs (like RT::CustomRole-ID)
+    # rather than role names.
+    if ( $data->{CustomRoles} ) {
+        %$data = ( %$data, %{ fix_custom_role_ids( $self->record, delete $data->{CustomRoles} ) } );
+    }
+
     my @results = $self->record->Update(
         ARGSRef       => $data,
         AttributesRef => [ $self->record->WritableAttributes ],

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

Summary of changes:
 Changes                                            |  4 ++
 META.yml                                           |  2 +-
 README                                             |  6 ++
 lib/RT/Extension/REST2.pm                          |  9 ++-
 lib/RT/Extension/REST2/Resource/Record/Writable.pm |  6 ++
 xt/ticket-customroles.t                            | 70 ++++++++++++++++++++++
 6 files changed, 95 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
rt-extension-rest2


More information about the Bps-public-commit mailing list