Bugzilla – Attachment 96114 Details for
Bug 24191
Sorting doesn't use to_model
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24191: Regression tests
Bug-24191-Regression-tests.patch (text/plain), 2.51 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-12-09 18:50:34 UTC
(
hide
)
Description:
Bug 24191: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-12-09 18:50:34 UTC
Size:
2.51 KB
patch
obsolete
>From 048425ae4c340ab4ab2b1bb2cc9c0da89bf4fd1c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 9 Dec 2019 14:41:35 -0300 >Subject: [PATCH] Bug 24191: Regression tests > >This patch adds missing tests for calling objects.search with >non-existent column names for sorting, that should be mapped using >to_model for that matter. > >Tests should fail as there's no current use of to_model for building the >order_by portion of the query. > >Sponsored-by: ByWater Solutions >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 43 ++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index 8c75d024a4..a65d949fc6 100644 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -50,6 +50,14 @@ get '/cities_to_model_to_api' => sub { > $c->render( status => 200, json => $cities ); > }; > >+get '/cities_sorted' => sub { >+ my $c = shift; >+ $c->validation->output($c->req->params->to_hash); >+ my $cities_set = Koha::Cities->new; >+ my $cities = $c->objects->search( $cities_set, \&to_model, \&to_api ); >+ $c->render( status => 200, json => $cities ); >+}; >+ > sub to_model { > my $params = shift; > >@@ -71,7 +79,7 @@ sub to_api { > } > > # The tests >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Mojo; > > use t::lib::TestBuilder; >@@ -233,3 +241,36 @@ subtest 'objects.search helper' => sub { > > $schema->storage->txn_rollback; > }; >+ >+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 >+ Koha::Cities->delete; >+ >+ $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'A', city_country => 'Argentina' } }); >+ $builder->build_object({ class => 'Koha::Cities', value => { city_name => 'B', city_country => 'Argentina' } }); >+ >+ $t->get_ok('/cities_sorted?_order_by=%2Bnombre&_order_by=+city_country') >+ ->status_is(200) >+ ->json_has('/0') >+ ->json_has('/1') >+ ->json_hasnt('/2') >+ ->json_is('/0/nombre' => 'A') >+ ->json_is('/1/nombre' => 'B'); >+ >+ $t->get_ok('/cities_sorted?_order_by=-nombre') >+ ->status_is(200) >+ ->json_has('/0') >+ ->json_has('/1') >+ ->json_hasnt('/2') >+ ->json_is('/0/nombre' => 'B') >+ ->json_is('/1/nombre' => 'A'); >+ >+ $schema->storage->txn_rollback; >+} >-- >2.24.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 24191
:
96114
|
96115
|
96116
|
96117
|
96118
|
96119
|
96133
|
96134
|
96135