Bugzilla – Attachment 134484 Details for
Bug 30536
Embeds should be defined in a single place
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30536: Fix Query.t Unit Test
Bug-30536-Fix-Queryt-Unit-Test.patch (text/plain), 3.61 KB, created by
Martin Renvoize (ashimema)
on 2022-05-03 07:10:33 UTC
(
hide
)
Description:
Bug 30536: Fix Query.t Unit Test
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-05-03 07:10:33 UTC
Size:
3.61 KB
patch
obsolete
>From 9f3d0896b0fba90385d3f548b4ff76794ebf0af2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 3 May 2022 08:06:41 +0100 >Subject: [PATCH] Bug 30536: Fix Query.t Unit Test > >The stash_embed method no longer validates the query so this patch drops >the validation tests and instead just focuses on varifying the correct >output structure of the stash after the method call. > >We have not lost validation however, it now happens only once at the >OpenAPI level and tests are present in t/db_dependent/api/v1/query.t >--- > t/Koha/REST/Plugin/Query.t | 75 ++++++-------------------------------- > 1 file changed, 12 insertions(+), 63 deletions(-) > >diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t >index 13103f3a29..5a3774599f 100755 >--- a/t/Koha/REST/Plugin/Query.t >+++ b/t/Koha/REST/Plugin/Query.t >@@ -209,50 +209,13 @@ get '/build_query' => sub { > get '/stash_embed' => sub { > my $c = shift; > >- try { >- $c->stash_embed( >- { >- spec => { >- 'x-koha-embed' => [ >- 'checkouts', >- 'checkouts.item', >- 'library', >- 'holds+count' >- ] >- } >- } >- ); >- >- $c->render( >- status => 200, >- json => $c->stash( 'koha.embed' ) >- ); >- } >- catch { >- $c->render( >- status => 400, >- json => { error => "$_" } >- ); >- }; >-}; >+ $c->stash_embed(); >+ my $embed = $c->stash('koha.embed'); > >-get '/stash_embed_no_spec' => sub { >- my $c = shift; >- >- try { >- $c->stash_embed({ spec => {} }); >- >- $c->render( >- status => 200, >- json => $c->stash( 'koha.embed' ) >- ); >- } >- catch { >- $c->render( >- status => 400, >- json => { error => "$_" } >- ); >- }; >+ $c->render( >+ status => 200, >+ json => $embed >+ ); > }; > > get '/stash_overrides' => sub { >@@ -466,38 +429,24 @@ subtest '_build_query_params_from_api' => sub { > > subtest 'stash_embed() tests' => sub { > >- plan tests => 15; >+ plan tests => 8; > > my $t = Test::Mojo->new; > > $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item' } ) >- ->status_is(200) >- ->json_is( { checkouts => { children => { item => {} } } } ); >+ ->json_is( { checkouts => { children => { item => { } } } } ); > > $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,library' } ) >- ->status_is(200) > ->json_is( { checkouts => { children => { item => {} } }, library => {} } ); > > $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'holds+count' } ) >- ->status_is(200) > ->json_is( { holds_count => { is_count => 1 } } ); > > $t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } ) >- ->status_is(400) >- ->json_is( >- { >- error => qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Embeding patron is not authorised. Check your x-koha-embed headers or remove it.'\n} >- } >- ); >- >- $t->get_ok( '/stash_embed_no_spec' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } ) >- ->status_is(400) >- ->json_is( >- { >- error => qq{Exception 'Koha::Exceptions::BadParameter' thrown 'Embedding objects is not allowed on this endpoint.'\n} >- } >- ); >- >+ ->json_is({ >+ checkouts => { children => { item => {} } }, >+ patron => {} >+ }); > }; > > subtest 'stash_overrides() tests' => sub { >-- >2.20.1
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 30536
:
133303
|
133309
|
133313
|
133314
|
133315
|
133316
|
133324
|
133325
|
133327
|
133328
|
133329
|
133330
|
134479
|
134480
|
134481
|
134482
|
134483
|
134484
|
134506
|
134507
|
134508
|
134509
|
134510
|
134511