Bugzilla – Attachment 170510 Details for
Bug 37672
V1/RecordSources.pm should use more helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37672: Make V1/RecordSources.pm use more helpers
Bug-37672-Make-V1RecordSourcespm-use-more-helpers.patch (text/plain), 2.88 KB, created by
David Nind
on 2024-08-21 04:05:57 UTC
(
hide
)
Description:
Bug 37672: Make V1/RecordSources.pm use more helpers
Filename:
MIME Type:
Creator:
David Nind
Created:
2024-08-21 04:05:57 UTC
Size:
2.88 KB
patch
obsolete
>From 53079fdca7a41cb3efb876e32fe5cf339042eb74 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 19 Aug 2024 09:27:38 -0300 >Subject: [PATCH] Bug 37672: Make V1/RecordSources.pm use more helpers > >This patch adapts the controller class to match the current guidelines >by makiing use of the provided helpers. > >The tests are adapted. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/REST/V1/RecordSources.pm | 29 +++++++------------------- > t/db_dependent/api/v1/record_sources.t | 2 +- > 2 files changed, 8 insertions(+), 23 deletions(-) > >diff --git a/Koha/REST/V1/RecordSources.pm b/Koha/REST/V1/RecordSources.pm >index 522b6943d3..46ce01b50f 100644 >--- a/Koha/REST/V1/RecordSources.pm >+++ b/Koha/REST/V1/RecordSources.pm >@@ -55,12 +55,8 @@ sub get { > > return try { > my $source = $c->objects->find( Koha::RecordSources->new, $c->param('record_source_id') ); >- unless ($source) { >- return $c->render( >- status => 404, >- openapi => { error => "Object not found" } >- ); >- } >+ return $c->render_resource_not_found("Record source") >+ unless $source; > > return $c->render( status => 200, openapi => $source ); > } catch { >@@ -97,12 +93,8 @@ sub update { > > my $source = $c->objects->find_rs( Koha::RecordSources->new, $c->param('record_source_id') ); > >- unless ($source) { >- return $c->render( >- status => 404, >- openapi => { error => "Object not found" } >- ); >- } >+ return $c->render_resource_not_found("Record source") >+ unless $source; > > return try { > $source->set_from_api( $c->req->json )->store; >@@ -122,19 +114,12 @@ sub delete { > > my $source = $c->objects->find_rs( Koha::RecordSources->new, $c->param('record_source_id') ); > >- unless ($source) { >- return $c->render( >- status => 404, >- openapi => { error => "Object not found" } >- ); >- } >+ return $c->render_resource_not_found("Record source") >+ unless $source; > > return try { > $source->delete; >- return $c->render( >- status => 204, >- openapi => q{} >- ); >+ return $c->render_resource_deleted; > } catch { > $c->unhandled_exception($_); > }; >diff --git a/t/db_dependent/api/v1/record_sources.t b/t/db_dependent/api/v1/record_sources.t >index f82264a714..09f3578375 100755 >--- a/t/db_dependent/api/v1/record_sources.t >+++ b/t/db_dependent/api/v1/record_sources.t >@@ -129,7 +129,7 @@ subtest 'get() tests' => sub { > $source->delete; > > $t->get_ok("//$userid:$password@/api/v1/record_sources/$id")->status_is(404) >- ->json_is( '/error' => 'Object not found' ); >+ ->json_is( '/error' => 'Record source not found' ); > > $schema->storage->txn_rollback; > }; >-- >2.39.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 37672
:
170465
|
170467
|
170510
|
170511
|
170569
|
170570