[Bps-public-commit] rt-extension-rest2 branch, master, updated. 1.09-25-g379f5ac

Jim Brandt jbrandt at bestpractical.com
Wed Apr 21 17:02:16 EDT 2021


The branch, master has been updated
       via  379f5ac6963f1b534cb7dc07cc171914756bacb8 (commit)
       via  a5fe371031c44d1d6697bc165c2f3d1a121eca65 (commit)
       via  8824c923d96800f79b09c83f77e18c238e00994d (commit)
       via  67624cc415ae173b83c91f4980709897ff4665ff (commit)
      from  7a8b27336c6470c69bcb4ceaa7bea75c1e6ee0d9 (commit)

Summary of changes:
 Changes                                    |  3 +++
 META.yml                                   |  2 +-
 lib/RT/Extension/REST2.pm                  |  2 +-
 lib/RT/Extension/REST2/Resource/Message.pm |  3 +--
 xt/tickets.t                               | 22 ++++++++++++++++++++++
 5 files changed, 28 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 67624cc415ae173b83c91f4980709897ff4665ff
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Thu Feb 18 12:05:45 2021 -0500

    Detect missing comment/correspond content in all cases
    
    Previously the NoContent flag was only set when attachments
    were included in the API call. Requests without Content would
    then process the JSON payload as the content and add it as
    text to the ticket without processing other data like setting
    Subject, etc.

diff --git a/lib/RT/Extension/REST2/Resource/Message.pm b/lib/RT/Extension/REST2/Resource/Message.pm
index e8d9266..48ffbf6 100644
--- a/lib/RT/Extension/REST2/Resource/Message.pm
+++ b/lib/RT/Extension/REST2/Resource/Message.pm
@@ -91,10 +91,9 @@ sub from_json {
                 unless $attachment->{$field};
             }
         }
-
-        $body->{NoContent} = 1 unless $body->{Content};
     }
 
+    $body->{NoContent} = 1 unless $body->{Content};
     if (!$body->{NoContent} && !$body->{ContentType}) {
         return error_as_json(
             $self->response,

commit 8824c923d96800f79b09c83f77e18c238e00994d
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Thu Feb 18 12:14:20 2021 -0500

    Test correspond without Content in JSON payload

diff --git a/xt/tickets.t b/xt/tickets.t
index 6c651d0..22706ff 100644
--- a/xt/tickets.t
+++ b/xt/tickets.t
@@ -467,6 +467,28 @@ my ($ticket_url, $ticket_id);
     is($content->{ContentType}, 'text/html');
 }
 
+# Ticket Reply, JSON request, missing Content
+{
+    my $res = $mech->get($ticket_url,
+        'Authorization' => $auth,
+    );
+    is($res->code, 200);
+    my $content = $mech->json_response;
+
+    my ($hypermedia) = grep { $_->{ref} eq 'correspond' } @{ $content->{_hyperlinks} };
+    ok($hypermedia, 'got correspond hypermedia');
+    like($hypermedia->{_url}, qr[$rest_base_path/ticket/$ticket_id/correspond$]);
+
+    $res = $mech->post($mech->url_for_hypermedia('correspond'),
+        'Authorization' => $auth,
+        'Content-Type' => 'application/json',
+        'Content' => '{"Subject":"No body!"}',
+    );
+    is($res->code, 201);
+
+    cmp_deeply($mech->json_response, [re(qr/Correspondence added|Message recorded/)]);
+}
+
 # Ticket Reply, changing status
 {
     my $res = $mech->get($ticket_url,

commit a5fe371031c44d1d6697bc165c2f3d1a121eca65
Merge: 7a8b273 8824c92
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Feb 19 11:52:33 2021 -0500

    Merge branch 'handle-missing-content-in-json'


commit 379f5ac6963f1b534cb7dc07cc171914756bacb8
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Feb 19 11:55:24 2021 -0500

    Prep 1.11 release

diff --git a/Changes b/Changes
index 800550d..5c6c8a1 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for RT-Extension-REST2
 
+1.11 2021-02-19
+ - Properly handle comment/correspond with no Content provided
+
 1.10 2021-02-12
  - Various documentation fixes and updates
  - Avoid errors for lazy-created custom role groups that may not
diff --git a/META.yml b/META.yml
index 4a063c4..9e3f83f 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.10'
+version: '1.11'
 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 f8123b5..fd6621c 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.10';
+our $VERSION = '1.11';
 our $REST_PATH = '/REST/2.0';
 
 use Plack::Builder;

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


More information about the Bps-public-commit mailing list