Bugzilla – Attachment 142381 Details for
Bug 17170
Add the ability to create 'saved searches' for use as filters when searching the catalog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17170: (QA follow-up) Spec cleanup
Bug-17170-QA-follow-up-Spec-cleanup.patch (text/plain), 9.42 KB, created by
Nick Clemens (kidclamp)
on 2022-10-21 13:35:36 UTC
(
hide
)
Description:
Bug 17170: (QA follow-up) Spec cleanup
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-10-21 13:35:36 UTC
Size:
9.42 KB
patch
obsolete
>From 1c535d12636cda892a170e4ed777fa18475b7de8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 6 Oct 2022 10:44:59 -0300 >Subject: [PATCH] Bug 17170: (QA follow-up) Spec cleanup > >This patch removes not required (for now) query parameters as we can >query using q= on those. They can be added back eventually, if needed. > >Attributes now match the database as well. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/SearchFilter.pm | 4 +- > Koha/SearchFilter.pm | 12 ---- > api/v1/swagger/definitions/search_filter.yaml | 4 +- > api/v1/swagger/paths/search_filters.yaml | 25 -------- > .../prog/en/modules/admin/search_filters.tt | 4 +- > t/db_dependent/api/v1/search_filters.t | 60 ++++++++----------- > 6 files changed, 31 insertions(+), 78 deletions(-) > >diff --git a/Koha/REST/V1/SearchFilter.pm b/Koha/REST/V1/SearchFilter.pm >index 05c72e7e9b..cf796a263f 100644 >--- a/Koha/REST/V1/SearchFilter.pm >+++ b/Koha/REST/V1/SearchFilter.pm >@@ -59,9 +59,7 @@ Controller function that handles retrieving a single Koha::AdvancedEditorMacro > > sub get { > my $c = shift->openapi->valid_input or return; >- my $filter = Koha::SearchFilters->find({ >- id => $c->validation->param('search_filter_id'), >- }); >+ my $filter = Koha::SearchFilters->find( $c->validation->param('search_filter_id') ); > unless ($filter) { > return $c->render( status => 404, > openapi => { error => "Search filter not found" } ); >diff --git a/Koha/SearchFilter.pm b/Koha/SearchFilter.pm >index 547e89a448..3683a89b28 100644 >--- a/Koha/SearchFilter.pm >+++ b/Koha/SearchFilter.pm >@@ -29,18 +29,6 @@ Koha::SearchFilter - Koha Search filter object class > > =head2 Class methods > >-=head3 to_api_mapping >- >-=cut >- >-sub to_api_mapping { >- return { >- id => 'search_filter_id', >- query => 'filter_query', >- limits => 'filter_limits', >- }; >-} >- > =head3 expand_filter > > my ($expanded_limit, $query_limit) = $filter->expand_filter; >diff --git a/api/v1/swagger/definitions/search_filter.yaml b/api/v1/swagger/definitions/search_filter.yaml >index a60e3f0ad4..c38f1239f0 100644 >--- a/api/v1/swagger/definitions/search_filter.yaml >+++ b/api/v1/swagger/definitions/search_filter.yaml >@@ -8,12 +8,12 @@ properties: > name: > description: filter name > type: string >- filter_query: >+ query: > description: filter query part > type: > - string > - 'null' >- filter_limits: >+ limits: > description: filter limits part > type: > - string >diff --git a/api/v1/swagger/paths/search_filters.yaml b/api/v1/swagger/paths/search_filters.yaml >index 5aa61e7350..03de8188d6 100644 >--- a/api/v1/swagger/paths/search_filters.yaml >+++ b/api/v1/swagger/paths/search_filters.yaml >@@ -9,31 +9,6 @@ > produces: > - application/json > parameters: >- - name: name >- in: query >- description: Case insensitive search on filter name >- required: false >- type: string >- - name: filter_query >- in: query >- description: Search on filter query part >- required: false >- type: string >- - name: filter_limits >- in: query >- description: Search on filter limits >- required: false >- type: string >- - name: opac >- in: query >- description: Display in OPAC >- required: false >- type: boolean >- - name: staff_client >- in: query >- description: Display on staff client >- required: false >- type: boolean > - $ref: "../swagger.yaml#/parameters/match" > - $ref: "../swagger.yaml#/parameters/order_by" > - $ref: "../swagger.yaml#/parameters/page" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt >index dce6e7db98..1305177426 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/search_filters.tt >@@ -117,12 +117,12 @@ > "orderable": true > }, > { >- "data": "filter_query", >+ "data": "query", > "searchable": true, > "orderable": true > }, > { >- "data": "filter_limits", >+ "data": "limits", > "searchable": true, > "orderable": true > }, >diff --git a/t/db_dependent/api/v1/search_filters.t b/t/db_dependent/api/v1/search_filters.t >index c0b1bb705a..f442f07edd 100755 >--- a/t/db_dependent/api/v1/search_filters.t >+++ b/t/db_dependent/api/v1/search_filters.t >@@ -33,10 +33,11 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > > my $t = Test::Mojo->new('Koha::REST::V1'); > >-$schema->storage->txn_begin; >- > subtest 'list() tests' => sub { >- plan tests => 10; >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; > > Koha::SearchFilters->search()->delete(); > >@@ -94,34 +95,15 @@ subtest 'list() tests' => sub { > ->json_has('/2/search_filter_id') > ->json_has('/3/search_filter_id'); > >- subtest 'query parameters' => sub { >- >- plan tests => 12; >- $t->get_ok("//$userid:$password@/api/v1/search_filters?name=" . $search_filter_2->name) >- ->status_is(200) >- ->json_is( [ $search_filter_2->to_api ] ); >- $t->get_ok("//$userid:$password@/api/v1/search_filters?name=NotAName") >- ->status_is(200) >- ->json_is( [ ] ); >- $t->get_ok("//$userid:$password@/api/v1/search_filters?filter_query=kw:any") >- ->status_is(200) >- ->json_is( [ $search_filter_3->to_api ] ); >- $t->get_ok("//$userid:$password@/api/v1/search_filters?filter_limits=mc-itype,phr:BK") >- ->status_is(200) >- ->json_is( [ $search_filter_1->to_api, $search_filter_2->to_api ] ); >- }; >- >- # Warn on unsupported query parameter >- $t->get_ok( "//$userid:$password@/api/v1/search_filters?filter_blah=blah" ) >- ->status_is(400) >- ->json_is( [{ path => '/query/filter_blah', message => 'Malformed query string'}] ); >- >+ $schema->storage->txn_rollback; > }; > > subtest 'get() tests' => sub { > > plan tests => 9; > >+ $schema->storage->txn_begin; >+ > my $patron = $builder->build_object({ > class => 'Koha::Patrons', > value => { flags => 3 } >@@ -150,12 +132,15 @@ subtest 'get() tests' => sub { > ->status_is( 401, 'Cannot search filters without permission' ) > ->json_is( '/error' => 'Authentication failure.' ); > >+ $schema->storage->txn_rollback; > }; > > subtest 'add() tests' => sub { > > plan tests => 17; > >+ $schema->storage->txn_begin; >+ > my $authorized_patron = $builder->build_object({ > class => 'Koha::Patrons', > value => { flags => 0 } >@@ -231,11 +216,15 @@ subtest 'add() tests' => sub { > ] > ); > >+ $schema->storage->txn_rollback; > }; > > subtest 'update() tests' => sub { >+ > plan tests => 15; > >+ $schema->storage->txn_begin; >+ > my $authorized_patron = $builder->build_object({ > class => 'Koha::Patrons', > value => { flags => 0 } >@@ -271,18 +260,18 @@ subtest 'update() tests' => sub { > ->status_is(403); > > my $search_filter_update = { >- name => "Filter update", >- filter_query => "ti:The hobbit", >- filter_limits => "mc-ccode:fantasy", >+ name => "Filter update", >+ query => "ti:The hobbit", >+ limits => "mc-ccode:fantasy", > }; > > my $test = $t->put_ok( "//$auth_userid:$password@/api/v1/search_filters/$search_filter_id" => json => $search_filter_update ) > ->status_is(200, 'Authorized user can update a macro') > ->json_is( '/search_filter_id' => $search_filter_id, 'We get back the id' ) >- ->json_is( '/name' => $search_filter_update->{name}, 'We get back the name' ) >- ->json_is( '/filter_query' => $search_filter_update->{filter_query}, 'We get back our query' ) >- ->json_is( '/filter_limits' => $search_filter_update->{filter_limits}, 'We get back our limits' ) >- ->json_is( '/opac' => 1, 'We get back our opac visibility unchanged' ) >+ ->json_is( '/name' => $search_filter_update->{name}, 'We get back the name' ) >+ ->json_is( '/query' => $search_filter_update->{query}, 'We get back our query' ) >+ ->json_is( '/limits' => $search_filter_update->{limits}, 'We get back our limits' ) >+ ->json_is( '/opac' => 1, 'We get back our opac visibility unchanged' ) > ->json_is( '/staff_client' => 1, 'We get back our staff client visibility unchanged' ); > > # Authorized attempt to write invalid data >@@ -307,11 +296,15 @@ subtest 'update() tests' => sub { > $t->put_ok("//$auth_userid:$password@/api/v1/search_filters/$non_existent_code" => json => $search_filter_update) > ->status_is(404); > >+ $schema->storage->txn_rollback; > }; > > subtest 'delete() tests' => sub { >+ > plan tests => 4; > >+ $schema->storage->txn_begin; >+ > my $authorized_patron = $builder->build_object({ > class => 'Koha::Patrons', > value => { flags => 0 } >@@ -348,6 +341,5 @@ subtest 'delete() tests' => sub { > $t->delete_ok( "//$auth_userid:$password@/api/v1/search_filters/$search_filter_id") > ->status_is( 204, 'Can delete search filter with permission'); > >+ $schema->storage->txn_rollback; > }; >- >-$schema->storage->txn_rollback; >-- >2.30.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 17170
:
133263
|
133264
|
133265
|
133266
|
133267
|
133268
|
133269
|
133270
|
133361
|
133376
|
137027
|
137028
|
137029
|
137030
|
137031
|
137032
|
137033
|
137034
|
137035
|
137036
|
137186
|
137187
|
137188
|
137189
|
137190
|
137191
|
137192
|
137193
|
137194
|
137195
|
137808
|
137809
|
137810
|
137811
|
137812
|
137813
|
137814
|
137815
|
137816
|
137817
|
138505
|
138506
|
138507
|
138508
|
138509
|
138510
|
138511
|
138512
|
138513
|
138514
|
139948
|
139949
|
139950
|
139951
|
139952
|
139953
|
139954
|
139955
|
139956
|
139957
|
141228
|
141229
|
141230
|
141231
|
141232
|
141233
|
141234
|
141235
|
141236
|
141237
|
141316
|
141317
|
141318
|
141319
|
141320
|
141321
|
141322
|
141323
|
141324
|
141325
|
141326
|
141327
|
141328
|
141348
|
141349
|
141350
|
141351
|
141352
|
141353
|
141354
|
141355
|
141356
|
141357
|
141358
|
141359
|
141360
|
141422
|
141423
|
141424
|
141425
|
141426
|
141427
|
141428
|
141429
|
141430
|
141431
|
141432
|
141433
|
141434
|
141435
|
141436
|
141437
|
141438
|
141461
|
141462
|
142365
|
142367
|
142368
|
142369
|
142370
|
142371
|
142372
|
142373
|
142374
|
142375
|
142376
|
142377
|
142378
|
142379
|
142380
| 142381 |
142382
|
142383
|
142384
|
142385
|
142494
|
142498