Bugzilla – Attachment 54156 Details for
Bug 17069
Can't create new patron category on the intranet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17069: Koha::Patron::Category->store must default checkprevcheckout to 'inherit'
Bug-17069-KohaPatronCategory-store-must-default-ch.patch (text/plain), 3.11 KB, created by
Marc Véron
on 2016-08-08 12:35:26 UTC
(
hide
)
Description:
Bug 17069: Koha::Patron::Category->store must default checkprevcheckout to 'inherit'
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2016-08-08 12:35:26 UTC
Size:
3.11 KB
patch
obsolete
>From 21d947aee0dc19035afabac4f3493b633eb0cdcc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 8 Aug 2016 10:48:36 +0100 >Subject: [PATCH] Bug 17069: Koha::Patron::Category->store must default > checkprevcheckout to 'inherit' > >Creating a new patron category raises an error "An error occurred when updating >this patron category. Perhaps it already exists." >DBIx::Class does not default to the value defined at the DB devel if the >key checkprevcheckout has been passed to the constructor. >We may need to provide a global fix for this kind of issue: if a column >is defined as "not null" but has a default value, the constructor >(Koha::Object->new) should not pass it to the DBIx::Class constructor >(even if assuming that null means default is a terrible mysqlism). > >Test plan: >Create a new patron category. > >Works as expected. >Signed-off-by: Marc <veron@veron.ch> >--- > Koha/Patron/Category.pm | 7 +++++++ > t/db_dependent/Koha/Patron/Categories.t | 7 ++++++- > 2 files changed, 13 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm >index 7b17c8c..06012ec 100644 >--- a/Koha/Patron/Category.pm >+++ b/Koha/Patron/Category.pm >@@ -35,6 +35,13 @@ Koha::Patron;;Category - Koha Patron;;Category Object class > > =cut > >+sub store { >+ my ( $self ) = @_; >+ $self->checkprevcheckout('inherit') >+ unless defined $self->checkprevcheckout; >+ return $self->SUPER::store; >+} >+ > =head3 default_messaging > > my $messaging = $category->default_messaging(); >diff --git a/t/db_dependent/Koha/Patron/Categories.t b/t/db_dependent/Koha/Patron/Categories.t >index 974b982..df0327c 100644 >--- a/t/db_dependent/Koha/Patron/Categories.t >+++ b/t/db_dependent/Koha/Patron/Categories.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 7; > > use Koha::Database; > use Koha::Patron::Category; >@@ -40,6 +40,7 @@ $new_category_1->add_branch_limitation( $branch->{branchcode} ); > my $new_category_2 = Koha::Patron::Category->new({ > categorycode => 'mycatcodeY', > description => 'mycatdescY', >+ checkprevcheckout => undef, > })->store; > > is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'The 2 patron categories should have been added' ); >@@ -49,6 +50,10 @@ is( $retrieved_category_1->categorycode, $new_category_1->categorycode, 'Find a > is_deeply( $retrieved_category_1->branch_limitations, [ $branch->{branchcode} ], 'The branch limitation should have been stored and retrieved' ); > is_deeply( $retrieved_category_1->default_messaging, [], 'By default there is not messaging option' ); > >+my $retrieved_category_2 = Koha::Patron::Categories->find( $new_category_2->categorycode ); >+is( $retrieved_category_1->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' ); >+is( $retrieved_category_2->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' ); >+ > $retrieved_category_1->delete; > is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' ); > >-- >2.1.4
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 17069
:
54147
|
54156
|
54245