Bugzilla – Attachment 112831 Details for
Bug 14708
The patron set as the anonymous patron should not be deletable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14708: (QA follow-up) Throw exception when deleting anonymous borrower
Bug-14708-QA-follow-up-Throw-exception-when-deleti.patch (text/plain), 2.39 KB, created by
Kyle M Hall (khall)
on 2020-11-02 13:13:55 UTC
(
hide
)
Description:
Bug 14708: (QA follow-up) Throw exception when deleting anonymous borrower
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-11-02 13:13:55 UTC
Size:
2.39 KB
patch
obsolete
>From 788637a4b91cda28bf9552a5878ae310a6f5ad67 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 2 Nov 2020 08:11:58 -0500 >Subject: [PATCH] Bug 14708: (QA follow-up) Throw exception when deleting > anonymous borrower > >--- > Koha/Exceptions/Patron.pm | 3 +++ > Koha/Patron.pm | 2 +- > t/db_dependent/Koha/Patrons.t | 6 ++++-- > 3 files changed, 8 insertions(+), 3 deletions(-) > >diff --git a/Koha/Exceptions/Patron.pm b/Koha/Exceptions/Patron.pm >index 8eac9c9366..069ed942c2 100644 >--- a/Koha/Exceptions/Patron.pm >+++ b/Koha/Exceptions/Patron.pm >@@ -9,6 +9,9 @@ use Exception::Class ( > 'Koha::Exceptions::Patron::FailedDelete' => { > description => "Deleting patron failed" > }, >+ 'Koha::Exceptions::Patron::FailedDeleteAnonymousPatron' => { >+ description => "Deleting patron failed, AnonymousPatron is not deleteable" >+ }, > ); > > 1; >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 8ff4462df1..14385aad9b 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -361,7 +361,7 @@ sub delete { > my ($self) = @_; > > my $anonymous_patron = C4::Context->preference("AnonymousPatron"); >- return $self if $anonymous_patron && $self->id eq $anonymous_patron; >+ Koha::Exceptions::Patron::FailedDeleteAnonymousPatron->throw() if $anonymous_patron && $self->id eq $anonymous_patron; > > $self->_result->result_source->schema->txn_do( > sub { >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 21b62e49ae..d27d2bba04 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1037,10 +1037,12 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); > > subtest 'Anonymous Patron should be undeleteable' => sub { >- plan tests => 1; >+ plan tests => 2; > > my $anonymous_patron = Koha::Patrons->find( $anonymous->{borrowernumber} ); >- $anonymous_patron->delete(); >+ throws_ok { $anonymous_patron->delete(); } >+ 'Koha::Exceptions::Patron::FailedDeleteAnonymousPatron', >+ 'Attempt to delete anonymous patron throws exception.'; > $anonymous_patron = Koha::Patrons->find( $anonymous->{borrowernumber} ); > is( $anonymous_patron->id, $anonymous->{borrowernumber}, "Anonymous Patron was not deleted" ); > }; >-- >2.24.1 (Apple Git-126)
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 14708
:
85766
|
85770
|
85783
|
85789
|
103026
|
103027
|
103028
|
103922
|
105024
|
105025
|
105026
|
105027
|
105028
|
105029
|
105184
|
105185
|
105186
|
105187
|
105188
|
105189
|
112830
| 112831 |
112922
|
113121