Bugzilla – Attachment 96965 Details for
Bug 18731
Add routes for acquisition orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18731: Use the stashed koha.embed in objects.search
Bug-18731-Use-the-stashed-kohaembed-in-objectssear.patch (text/plain), 3.57 KB, created by
Kyle M Hall (khall)
on 2020-01-07 20:30:19 UTC
(
hide
)
Description:
Bug 18731: Use the stashed koha.embed in objects.search
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-01-07 20:30:19 UTC
Size:
3.57 KB
patch
obsolete
>From 9bb2a57daa63df1b583a01dd78dd5b3e98169634 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 6 Jan 2020 13:00:26 -0300 >Subject: [PATCH] Bug 18731: Use the stashed koha.embed in objects.search > >This patch makes the objects.search helper use the koha.embed structure >that is embedded in the authenticate_api_request step. > >This way, any controller using it will benefit from automatic embed >handling. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/Plugin/Objects.pm | 4 ++- > t/db_dependent/Koha/REST/Plugin/Objects.t | 36 ++++++++++++++++++----- > 2 files changed, 31 insertions(+), 9 deletions(-) > >diff --git a/Koha/REST/Plugin/Objects.pm b/Koha/REST/Plugin/Objects.pm >index e8f0616f94..4ce9c5134d 100644 >--- a/Koha/REST/Plugin/Objects.pm >+++ b/Koha/REST/Plugin/Objects.pm >@@ -51,6 +51,8 @@ sub register { > > # Extract reserved params > my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($args); >+ # Look for embeds >+ my $embed = $c->stash('koha.embed'); > > # Merge sorting into query attributes > $c->dbic_merge_sorting( >@@ -87,7 +89,7 @@ sub register { > }); > } > >- return $objects->to_api; >+ return $objects->to_api({ embed => $embed }); > } > ); > } >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index c1a76de564..2e162b21bc 100644 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -16,6 +16,8 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+ >+use Koha::Acquisition::Orders; > use Koha::Cities; > > # Dummy app for testing the plugin >@@ -34,24 +36,30 @@ get '/cities' => sub { > $c->render( status => 200, json => $cities ); > }; > >+get '/orders' => sub { >+ my $c = shift; >+ $c->stash('koha.embed', ( { fund => {} } ) ); >+ $c->validation->output($c->req->params->to_hash); >+ my $orders = $c->objects->search(Koha::Acquisition::Orders->new); >+ $c->render( status => 200, json => $orders ); >+}; >+ > # The tests >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Mojo; > > use t::lib::TestBuilder; > use Koha::Database; > >-my $schema = Koha::Database->new()->schema(); >- >+my $t = Test::Mojo->new; > >+my $schema = Koha::Database->new()->schema(); > my $builder = t::lib::TestBuilder->new; > > subtest 'objects.search helper' => sub { > > plan tests => 34; > >- my $t = Test::Mojo->new; >- > $schema->storage->txn_begin; > > # Remove existing cities to have more control on the search restuls >@@ -128,8 +136,6 @@ subtest 'objects.search helper, sorting on mapped column' => sub { > > plan tests => 14; > >- my $t = Test::Mojo->new; >- > $schema->storage->txn_begin; > > # Have complete control over the existing cities to ease testing >@@ -155,4 +161,18 @@ subtest 'objects.search helper, sorting on mapped column' => sub { > ->json_is('/1/name' => 'A'); > > $schema->storage->txn_rollback; >-} >+}; >+ >+subtest 'objects.search helper, embed' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); >+ >+ $t->get_ok('/orders?order_id=' . $order->ordernumber) >+ ->json_is('/0',$order->to_api({ embed => ( { fund => {} } ) })); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.21.0 (Apple Git-122.2)
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 18731
:
69184
|
69185
|
69309
|
69310
|
69544
|
73959
|
73960
|
78435
|
78436
|
84133
|
84134
|
95054
|
95055
|
95056
|
96853
|
96854
|
96855
|
96856
|
96857
|
96858
|
96916
|
96917
|
96918
|
96938
|
96961
|
96962
|
96963
|
96964
|
96965
|
96966
|
97107
|
97108
|
97109
|
97110
|
97111
|
97112
|
97113
|
97331