[Bps-public-commit] rt-extension-rest2 branch, master, updated. 2f83f43d96109ca8c751324a1e76dcdb13e7bbb8

Shawn Moore shawn at bestpractical.com
Tue Dec 13 15:45:33 EST 2016


The branch, master has been updated
       via  2f83f43d96109ca8c751324a1e76dcdb13e7bbb8 (commit)
       via  dae543320e0475b56a00143c383e7d46c2d806b2 (commit)
      from  41d9f3d6926a77a65531933c67c3dcfed3db2c5e (commit)

Summary of changes:
 lib/RT/Extension/REST2/Resource/Catalog.pm         |  8 +++++---
 .../REST2/Resource/Collection/QueryByJSON.pm       |  8 +++++---
 lib/RT/Extension/REST2/Resource/Queue.pm           |  8 +++++---
 lib/RT/Extension/REST2/Resource/Ticket.pm          | 23 +++++++++++++++++++---
 lib/RT/Extension/REST2/Resource/User.pm            |  8 +++++---
 t/tickets.t                                        |  3 +++
 6 files changed, 43 insertions(+), 15 deletions(-)

- Log -----------------------------------------------------------------
commit dae543320e0475b56a00143c383e7d46c2d806b2
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Dec 13 20:41:42 2016 +0000

    Combine roles as we consume them to detect method conflicts

diff --git a/lib/RT/Extension/REST2/Resource/Catalog.pm b/lib/RT/Extension/REST2/Resource/Catalog.pm
index b086936..8eee13d 100644
--- a/lib/RT/Extension/REST2/Resource/Catalog.pm
+++ b/lib/RT/Extension/REST2/Resource/Catalog.pm
@@ -6,9 +6,11 @@ use Moose;
 use namespace::autoclean;
 
 extends 'RT::Extension::REST2::Resource::Record';
-with 'RT::Extension::REST2::Resource::Record::Readable';
-with 'RT::Extension::REST2::Resource::Record::DeletableByDisabling';
-with 'RT::Extension::REST2::Resource::Record::Writable';
+with (
+    'RT::Extension::REST2::Resource::Record::Readable',
+    'RT::Extension::REST2::Resource::Record::DeletableByDisabling',
+    'RT::Extension::REST2::Resource::Record::Writable',
+);
 
 __PACKAGE__->meta->make_immutable;
 
diff --git a/lib/RT/Extension/REST2/Resource/Collection/QueryByJSON.pm b/lib/RT/Extension/REST2/Resource/Collection/QueryByJSON.pm
index 31d505f..0bd19d9 100644
--- a/lib/RT/Extension/REST2/Resource/Collection/QueryByJSON.pm
+++ b/lib/RT/Extension/REST2/Resource/Collection/QueryByJSON.pm
@@ -7,9 +7,11 @@ use namespace::autoclean;
 
 use JSON ();
 
-with 'RT::Extension::REST2::Resource::Collection::ProcessPOSTasGET';
-with 'RT::Extension::REST2::Resource::Role::RequestBodyIsJSON'
-     => { type => 'ARRAY' };
+with (
+    'RT::Extension::REST2::Resource::Collection::ProcessPOSTasGET',
+    'RT::Extension::REST2::Resource::Role::RequestBodyIsJSON'
+         => { type => 'ARRAY' },
+);
 
 requires 'collection';
 
diff --git a/lib/RT/Extension/REST2/Resource/Queue.pm b/lib/RT/Extension/REST2/Resource/Queue.pm
index 0c169eb..10ec15a 100644
--- a/lib/RT/Extension/REST2/Resource/Queue.pm
+++ b/lib/RT/Extension/REST2/Resource/Queue.pm
@@ -6,9 +6,11 @@ use Moose;
 use namespace::autoclean;
 
 extends 'RT::Extension::REST2::Resource::Record';
-with 'RT::Extension::REST2::Resource::Record::Readable';
-with 'RT::Extension::REST2::Resource::Record::DeletableByDisabling';
-with 'RT::Extension::REST2::Resource::Record::Writable';
+with (
+    'RT::Extension::REST2::Resource::Record::Readable',
+    'RT::Extension::REST2::Resource::Record::DeletableByDisabling',
+    'RT::Extension::REST2::Resource::Record::Writable',
+);
 
 __PACKAGE__->meta->make_immutable;
 
diff --git a/lib/RT/Extension/REST2/Resource/Ticket.pm b/lib/RT/Extension/REST2/Resource/Ticket.pm
index 8ea6370..dd44fa5 100644
--- a/lib/RT/Extension/REST2/Resource/Ticket.pm
+++ b/lib/RT/Extension/REST2/Resource/Ticket.pm
@@ -6,9 +6,11 @@ use Moose;
 use namespace::autoclean;
 
 extends 'RT::Extension::REST2::Resource::Record';
-with 'RT::Extension::REST2::Resource::Record::Readable';
-with 'RT::Extension::REST2::Resource::Record::Deletable';
-with 'RT::Extension::REST2::Resource::Record::Writable';
+with (
+    'RT::Extension::REST2::Resource::Record::Readable'
+    'RT::Extension::REST2::Resource::Record::Deletable',
+    'RT::Extension::REST2::Resource::Record::Writable',
+);
 
 sub create_record {
     my $self = shift;
diff --git a/lib/RT/Extension/REST2/Resource/User.pm b/lib/RT/Extension/REST2/Resource/User.pm
index 9d35b48..44b2367 100644
--- a/lib/RT/Extension/REST2/Resource/User.pm
+++ b/lib/RT/Extension/REST2/Resource/User.pm
@@ -6,9 +6,11 @@ use Moose;
 use namespace::autoclean;
 
 extends 'RT::Extension::REST2::Resource::Record';
-with 'RT::Extension::REST2::Resource::Record::Readable';
-with 'RT::Extension::REST2::Resource::Record::DeletableByDisabling';
-with 'RT::Extension::REST2::Resource::Record::Writable';
+with (
+    'RT::Extension::REST2::Resource::Record::Readable',
+    'RT::Extension::REST2::Resource::Record::DeletableByDisabling',
+    'RT::Extension::REST2::Resource::Record::Writable',
+);
 
 around 'serialize' => sub {
     my $orig = shift;

commit 2f83f43d96109ca8c751324a1e76dcdb13e7bbb8
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Dec 13 20:44:49 2016 +0000

    Add history hypermedia link to ticket

diff --git a/lib/RT/Extension/REST2/Resource/Ticket.pm b/lib/RT/Extension/REST2/Resource/Ticket.pm
index dd44fa5..40c0f33 100644
--- a/lib/RT/Extension/REST2/Resource/Ticket.pm
+++ b/lib/RT/Extension/REST2/Resource/Ticket.pm
@@ -8,6 +8,7 @@ use namespace::autoclean;
 extends 'RT::Extension::REST2::Resource::Record';
 with (
     'RT::Extension::REST2::Resource::Record::Readable'
+        => { -alias => { hypermedia_links => '_default_hypermedia_links' } },
     'RT::Extension::REST2::Resource::Record::Deletable',
     'RT::Extension::REST2::Resource::Record::Writable',
 );
@@ -25,6 +26,20 @@ sub forbidden {
     return !$self->record->CurrentUserHasRight('ShowTicket');
 }
 
+sub hypermedia_links {
+    my $self = shift;
+    my $links = $self->_default_hypermedia_links(@_);
+
+    my $class = 'ticket';
+    my $id = $self->record->id;
+
+    push @$links, {
+        ref  => 'history',
+        _url => RT::Extension::REST2->base_uri . "/$class/$id/history",
+    };
+    return $links;
+}
+
 __PACKAGE__->meta->make_immutable;
 
 1;
diff --git a/t/tickets.t b/t/tickets.t
index 805b8ee..ad10175 100644
--- a/t/tickets.t
+++ b/t/tickets.t
@@ -97,6 +97,9 @@ my ($ticket_url, $ticket_id);
     is($links->[0]{type}, 'ticket');
     like($links->[0]{_url}, qr[$rest_base_path/ticket/$ticket_id$]);
 
+    is($links->[1]{ref}, 'history');
+    like($links->[1]{_url}, qr[$rest_base_path/ticket/$ticket_id/history$]);
+
     my $queue = $content->{Queue};
     is($queue->{id}, 1);
     is($queue->{type}, 'queue');

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


More information about the Bps-public-commit mailing list