Bugzilla – Attachment 114937 Details for
Bug 27358
Add GET /public/biblios/:biblio_id/items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27358: Teach objects.search about public requests
Bug-27358-Teach-objectssearch-about-public-request.patch (text/plain), 2.87 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-01-07 18:49:44 UTC
(
hide
)
Description:
Bug 27358: Teach objects.search about public requests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-01-07 18:49:44 UTC
Size:
2.87 KB
patch
obsolete
>From b7a2fc114f8ce9a9720703de0444a9565c1c9f2c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 7 Jan 2021 13:18:27 -0300 >Subject: [PATCH] Bug 27358: Teach objects.search about public requests > >--- > Koha/REST/Plugin/Objects.pm | 4 ++- > t/db_dependent/Koha/REST/Plugin/Objects.t | 40 +++++++++++++++++++++-- > 2 files changed, 41 insertions(+), 3 deletions(-) > >diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm >index 0f08a2d37a..9be577515e 100644 >--- a/Koha/REST/Plugin/Objects.pm >+++ b/Koha/REST/Plugin/Objects.pm >@@ -53,6 +53,8 @@ sub register { > > # Extract reserved params > my ( $filtered_params, $reserved_params, $path_params ) = $c->extract_reserved_params($args); >+ # Privileged reques? >+ my $is_public = $c->stash('is_public'); > # Look for embeds > my $embed = $c->stash('koha.embed'); > >@@ -138,7 +140,7 @@ sub register { > }); > } > >- return $objects->to_api({ embed => $embed }); >+ return $objects->to_api({ embed => $embed, public => $is_public }); > } > ); > } >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index cbec228ce9..370b2aa81d 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -75,9 +75,27 @@ get '/biblios' => sub { > $c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); > }; > >+get '/items/:item_id_1/:item_id_2' => sub { >+ >+ my $c = shift; >+ >+ # Emulate a public route by stashing the is_public value >+ $c->stash( 'is_public' => 1 ); >+ >+ my $item_id_1 = $c->param('item_id_1'); >+ my $item_id_2 = $c->param('item_id_2'); >+ >+ my $items_rs = Koha::Items->search({ itemnumber => [ $item_id_1, $item_id_2 ] }); >+ my $items = $c->objects->search( $items_rs ); >+ >+ $c->render( >+ status => 200, >+ json => $items >+ ); >+}; > > # The tests >-use Test::More tests => 10; >+use Test::More tests => 11; > use Test::Mojo; > > use t::lib::Mocks; >@@ -423,4 +441,22 @@ subtest 'object.search helper order by embedded columns' => sub { > ->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); > > $schema->storage->txn_begin; >-} >+}; >+ >+subtest 'objects.search helper, public requests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $item_1 = $builder->build_sample_item; >+ my $item_2 = $builder->build_sample_item; >+ >+ my $t = Test::Mojo->new; >+ >+ $t->get_ok( '/items/'.$item_1->id.'/'.$item_2->id ) >+ ->json_is('/0' => $item_1->to_api({ public => 1 }), 'Public representation of $item_1 is retrieved') >+ ->json_is('/1' => $item_2->to_api({ public => 1 }), 'Public representation of $item_2 is retrieved'); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27358
:
114922
|
114935
|
114936
|
114937
|
114938
|
114939
|
116187
|
116188
|
116189
|
116190
|
116191
|
123843
|
123844
|
123845
|
123846
|
123847
|
124454
|
124455
|
124456
|
124457
|
124458
|
124459
|
126156
|
126157
|
126158
|
126159
|
126164
|
126165
|
126971
|
126972