Bugzilla – Attachment 125739 Details for
Bug 27947
Add default cancellation reasons to article requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27947: (QA follow-up) Make parameters a hashref
Bug-27947-QA-follow-up-Make-parameters-a-hashref.patch (text/plain), 4.01 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-05 14:16:48 UTC
(
hide
)
Description:
Bug 27947: (QA follow-up) Make parameters a hashref
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-05 14:16:48 UTC
Size:
4.01 KB
patch
obsolete
>From 31eba0e77952fc3c15b82772f92190f4650cc7e8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 5 Oct 2021 11:10:10 -0300 >Subject: [PATCH] Bug 27947: (QA follow-up) Make parameters a hashref > >This patch makes the Koha::ArticleRequest->cancel parameters into a >hashref. (Missing) tests are added for those parameters being set as >well. > >Calls to ->cancel are updated. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/ArticleRequest.t \ > t/db_dependent/api/v1/article_requests.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/ArticleRequest.pm | 5 ++++- > Koha/REST/V1/ArticleRequests.pm | 18 ++++++++++++++---- > svc/article_request | 2 +- > t/db_dependent/Koha/ArticleRequest.t | 9 +++++++-- > 4 files changed, 26 insertions(+), 8 deletions(-) > >diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm >index 5d036a0283..e03af23173 100644 >--- a/Koha/ArticleRequest.pm >+++ b/Koha/ArticleRequest.pm >@@ -122,7 +122,10 @@ Marks the article as cancelled. Send a notification if appropriate. > =cut > > sub cancel { >- my ( $self, $cancellation_reason, $notes ) = @_; >+ my ( $self, $params ) = @_; >+ >+ my $cancellation_reason = $params->{cancellation_reason}; >+ my $notes = $params->{notes}; > > $self->status(Koha::ArticleRequest::Status::Canceled); > $self->cancellation_reason($cancellation_reason) if $cancellation_reason; >diff --git a/Koha/REST/V1/ArticleRequests.pm b/Koha/REST/V1/ArticleRequests.pm >index 58e3f4bfef..af6884174e 100644 >--- a/Koha/REST/V1/ArticleRequests.pm >+++ b/Koha/REST/V1/ArticleRequests.pm >@@ -52,11 +52,16 @@ sub cancel { > } > > my $reason = $c->validation->param('cancellation_reason'); >- my $notes = $c->validation->param('notes'); >+ my $notes = $c->validation->param('notes'); > > return try { > >- $article_request->cancel($reason, $notes); >+ $article_request->cancel( >+ { >+ cancellation_reason => $reason, >+ notes => $notes >+ } >+ ); > return $c->render( > status => 204, > openapi => q{} >@@ -96,11 +101,16 @@ sub patron_cancel { > } > > my $reason = $c->validation->param('cancellation_reason'); >- my $notes = $c->validation->param('notes'); >+ my $notes = $c->validation->param('notes'); > > return try { > >- $article_request->cancel( $reason, $notes ); >+ $article_request->cancel( >+ { >+ cancellation_reason => $reason, >+ notes => $notes >+ } >+ ); > return $c->render( > status => 204, > openapi => q{} >diff --git a/svc/article_request b/svc/article_request >index 3b5105ad0d..e8c8e7f819 100755 >--- a/svc/article_request >+++ b/svc/article_request >@@ -45,7 +45,7 @@ my $ar = Koha::ArticleRequests->find($id); > > if ($ar) { > if ( $action eq 'cancel' ) { >- $ar = $ar->cancel( $notes ); >+ $ar = $ar->cancel({ notes => $notes }); > } > elsif ( $action eq 'process' ) { > $ar = $ar->process(); >diff --git a/t/db_dependent/Koha/ArticleRequest.t b/t/db_dependent/Koha/ArticleRequest.t >index e4caffbdfd..2f851f3c1c 100755 >--- a/t/db_dependent/Koha/ArticleRequest.t >+++ b/t/db_dependent/Koha/ArticleRequest.t >@@ -116,7 +116,7 @@ subtest 'complete() tests' => sub { > > subtest 'cancel() tests' => sub { > >- plan tests => 2; >+ plan tests => 4; > > $schema->storage->txn_begin; > >@@ -129,9 +129,14 @@ subtest 'cancel() tests' => sub { > } > ); > >- $ar->cancel()->discard_changes; >+ my $reason = "Hey, ho"; >+ my $notes = "Let's go!"; >+ >+ $ar->cancel({ cancellation_reason => $reason, notes => $notes })->discard_changes; > > is( $ar->status, Koha::ArticleRequest::Status::Canceled ); >+ is( $ar->cancellation_reason, $reason, 'Cancellation reason stored correctly' ); >+ is( $ar->notes, $notes, 'Notes stored correctly' ); > > $schema->storage->txn_rollback; > }; >-- >2.32.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 27947
:
124063
|
124064
|
124065
|
124849
|
124850
|
124851
|
124952
|
124953
|
124954
|
124955
|
124956
|
124993
|
124994
|
124995
|
124996
|
124997
|
124998
|
124999
|
125002
|
125003
|
125004
|
125005
|
125006
|
125007
|
125008
|
125009
|
125010
|
125016
|
125038
|
125039
|
125040
|
125041
|
125042
|
125043
|
125044
|
125045
|
125046
|
125047
|
125165
|
125166
|
125167
|
125168
|
125169
|
125170
|
125171
|
125172
|
125173
|
125174
| 125739 |
125740