[Bps-public-commit] rt-extension-rest2 branch, transaction-cfs, updated. 1.07-8-gf7de9be

Jim Brandt jbrandt at bestpractical.com
Fri Aug 16 09:30:09 EDT 2019


The branch, transaction-cfs has been updated
       via  f7de9be5b32583e1d13b2d969f4771cd1a9af90a (commit)
       via  77e3d0e2522b44d8340bb4d7217d8c7c8eeb76df (commit)
       via  eb6298600a231888c5a8398480019771ebe4a441 (commit)
      from  cf8a9eb55e7a0d5b784b933b48852c6afa448ef0 (commit)

Summary of changes:
 Changes                                            |  4 ++++
 MANIFEST                                           |  1 +
 META.yml                                           |  2 +-
 lib/RT/Extension/REST2.pm                          |  2 +-
 .../Extension/REST2/Resource/Record/Hypermedia.pm  |  1 +
 lib/RT/Extension/REST2/Util.pm                     |  7 +++++-
 xt/asset-customfields.t                            |  2 ++
 xt/queues.t                                        | 26 +++++++++++++++++-----
 xt/ticket-customfields.t                           |  2 ++
 9 files changed, 38 insertions(+), 9 deletions(-)

- Log -----------------------------------------------------------------
commit eb6298600a231888c5a8398480019771ebe4a441
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Aug 9 16:42:28 2019 -0400

    Prep 1.08 release

diff --git a/Changes b/Changes
index c756d8c..3fb4d27 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for RT-Extension-REST2
 
+1.08 2019-08-09
+ - Accept transaction custom fields on comment/correspond
+ - Accept ticket custom fields on comment/correspond
+
 1.07 2019-05-24
  - Accept 'Content' as a parameter on create. The documentation previously showed
    this in examples, but it wasn't yet supported. Now it works as documented.
diff --git a/MANIFEST b/MANIFEST
index 7ef88eb..3b90cd6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -82,6 +82,7 @@ xt/ticket-links.t
 xt/ticket-watchers.t
 xt/tickets-bulk.t
 xt/tickets.t
+xt/transaction-customfields.t
 xt/transactions.t
 xt/user-customfields.t
 xt/user-memberships.t
diff --git a/META.yml b/META.yml
index 65f84bc..c870959 100644
--- a/META.yml
+++ b/META.yml
@@ -43,6 +43,6 @@ requires:
   perl: 5.10.1
 resources:
   license: http://opensource.org/licenses/gpl-license.php
-version: '1.07'
+version: '1.08'
 x_module_install_rtx_version: '0.40'
 x_requires_rt: 4.2.4
diff --git a/lib/RT/Extension/REST2.pm b/lib/RT/Extension/REST2.pm
index e0315c5..64bdc9b 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.07';
+our $VERSION = '1.08';
 our $REST_PATH = '/REST/2.0';
 
 use Plack::Builder;

commit 77e3d0e2522b44d8340bb4d7217d8c7c8eeb76df
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Aug 16 09:03:01 2019 -0400

    Return custom field information for queues
    
    RT::Queue uses the method TicketCustomFields rather than the
    standard CustomFields used by other RT objects. Add special
    handling for RT::Queue to return custom field information for
    queues.

diff --git a/lib/RT/Extension/REST2/Util.pm b/lib/RT/Extension/REST2/Util.pm
index e59a69c..b056629 100644
--- a/lib/RT/Extension/REST2/Util.pm
+++ b/lib/RT/Extension/REST2/Util.pm
@@ -242,7 +242,12 @@ sub custom_fields_for {
             }
         }
         else {
-            return $record->CustomFields;
+            if ( ref($record) eq 'RT::Queue' ) {
+                return $record->TicketCustomFields;
+            }
+            else {
+                return $record->CustomFields;
+            }
         }
     }
 
diff --git a/xt/queues.t b/xt/queues.t
index a8396b2..8fcb097 100644
--- a/xt/queues.t
+++ b/xt/queues.t
@@ -9,6 +9,13 @@ my $user = RT::Extension::REST2::Test->user;
 
 $user->PrincipalObj->GrantRight( Right => 'SuperUser' );
 
+my $queue_obj = RT::Test->load_or_create_queue( Name => "General" );
+
+my $single_cf = RT::CustomField->new( RT->SystemUser );
+my ($ok, $msg) = $single_cf->Create( Name => 'Single', Type => 'FreeformSingle', Queue => $queue_obj->Id );
+ok($ok, $msg);
+my $single_cf_id = $single_cf->Id;
+
 my $queue_url;
 # search Name = General
 {
@@ -51,19 +58,22 @@ my $queue_url;
     ok(exists $content->{$_}, "got $_") for @fields;
 
     my $links = $content->{_hyperlinks};
-    is(scalar @$links, 3);
+    is(scalar @$links, 4);
 
     is($links->[0]{ref}, 'self');
     is($links->[0]{id}, 1);
     is($links->[0]{type}, 'queue');
     like($links->[0]{_url}, qr[$rest_base_path/queue/1$]);
 
-    is($links->[1]{ref}, 'history');
-    like($links->[1]{_url}, qr[$rest_base_path/queue/1/history$]);
+    is($links->[1]{ref}, 'customfield');
+    like($links->[1]{_url}, qr[$rest_base_path/customfield/$single_cf_id$]);
 
-    is($links->[2]{ref}, 'create');
-    is($links->[2]{type}, 'ticket');
-    like($links->[2]{_url}, qr[$rest_base_path/ticket\?Queue=1$]);
+    is($links->[2]{ref}, 'history');
+    like($links->[2]{_url}, qr[$rest_base_path/queue/1/history$]);
+
+    is($links->[3]{ref}, 'create');
+    is($links->[3]{type}, 'ticket');
+    like($links->[3]{_url}, qr[$rest_base_path/ticket\?Queue=1$]);
 
     my $creator = $content->{Creator};
     is($creator->{id}, 'RT_System');
@@ -75,6 +85,9 @@ my $queue_url;
     is($updated_by->{type}, 'user');
     like($updated_by->{_url}, qr{$rest_base_path/user/RT_System$});
 
+    my $cfs = $content->{CustomFields};
+    ok( $cfs->{$single_cf_id}, 'Returned custom field ' . $single_cf->Name . ' applied to queue' );
+
     is_deeply($content->{Cc}, [], 'no Ccs set');
     is_deeply($content->{AdminCc}, [], 'no AdminCcs set');
 

commit f7de9be5b32583e1d13b2d969f4771cd1a9af90a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Aug 16 09:24:13 2019 -0400

    Add custom field names in hyperlink data

diff --git a/lib/RT/Extension/REST2/Resource/Record/Hypermedia.pm b/lib/RT/Extension/REST2/Resource/Record/Hypermedia.pm
index 93e6d85..2f27431 100644
--- a/lib/RT/Extension/REST2/Resource/Record/Hypermedia.pm
+++ b/lib/RT/Extension/REST2/Resource/Record/Hypermedia.pm
@@ -91,6 +91,7 @@ sub _customfield_links {
             push @links, {
                 %$entry,
                 ref => 'customfield',
+                name => $cf->Name,
             };
         }
     }
diff --git a/xt/asset-customfields.t b/xt/asset-customfields.t
index 499c400..d16bb73 100644
--- a/xt/asset-customfields.t
+++ b/xt/asset-customfields.t
@@ -119,11 +119,13 @@ my ($asset_url, $asset_id);
         [{
             ref => 'customfield',
             id  => $single_cf_id,
+            name => 'Single',
             type => 'customfield',
             _url => re(qr[$rest_base_path/customfield/$single_cf_id$]),
         }, {
             ref => 'customfield',
             id  => $multi_cf_id,
+            name => 'Multi',
             type => 'customfield',
             _url => re(qr[$rest_base_path/customfield/$multi_cf_id$]),
         }],
diff --git a/xt/queues.t b/xt/queues.t
index 8fcb097..2cea517 100644
--- a/xt/queues.t
+++ b/xt/queues.t
@@ -67,6 +67,7 @@ my $queue_url;
 
     is($links->[1]{ref}, 'customfield');
     like($links->[1]{_url}, qr[$rest_base_path/customfield/$single_cf_id$]);
+    is($links->[1]{name}, 'Single');
 
     is($links->[2]{ref}, 'history');
     like($links->[2]{_url}, qr[$rest_base_path/queue/1/history$]);
diff --git a/xt/ticket-customfields.t b/xt/ticket-customfields.t
index d276ff3..d414a3b 100644
--- a/xt/ticket-customfields.t
+++ b/xt/ticket-customfields.t
@@ -115,11 +115,13 @@ my ($ticket_url, $ticket_id);
         [{
             ref => 'customfield',
             id  => $single_cf_id,
+            name => 'Single',
             type => 'customfield',
             _url => re(qr[$rest_base_path/customfield/$single_cf_id$]),
         }, {
             ref => 'customfield',
             id  => $multi_cf_id,
+            name => 'Multi',
             type => 'customfield',
             _url => re(qr[$rest_base_path/customfield/$multi_cf_id$]),
         }],

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


More information about the Bps-public-commit mailing list