Bugzilla – Attachment 53029 Details for
Bug 14048
Change RefundLostItemFeeOnReturn to be branch specific
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14048: (QA followup) Default to 1 if no default rule
Bug-14048-QA-followup-Default-to-1-if-no-default-r.patch (text/plain), 4.44 KB, created by
Jonathan Druart
on 2016-07-01 14:48:46 UTC
(
hide
)
Description:
Bug 14048: (QA followup) Default to 1 if no default rule
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-07-01 14:48:46 UTC
Size:
4.44 KB
patch
obsolete
>From 98f321e3fdc11c0cb34bf7df7df34fc2be862b6a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 27 Jun 2016 10:17:20 -0300 >Subject: [PATCH] Bug 14048: (QA followup) Default to 1 if no default rule > >This patch answers Jonathan's request to simplify this patchset a bit. > >It removes the need for the .sql file, as _default_rule now defaults to >a fixed value (1, which was set by the removed .sql file). >This allowed to remove the overloaded ->delete method. > >The tests have been adjusted to reflect this changes, including tests for >the new 'default'-if-absent situation. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/RefundLostItemFeeRule.pm | 18 ------------------ > Koha/RefundLostItemFeeRules.pm | 8 ++++++-- > .../mysql/mandatory/refund_lost_item_fee_rules.sql | 2 -- > t/db_dependent/RefundLostItemFeeRule.t | 17 +++++++---------- > 4 files changed, 13 insertions(+), 32 deletions(-) > delete mode 100644 installer/data/mysql/mandatory/refund_lost_item_fee_rules.sql > >diff --git a/Koha/RefundLostItemFeeRule.pm b/Koha/RefundLostItemFeeRule.pm >index 2a58c06..56e4d93 100644 >--- a/Koha/RefundLostItemFeeRule.pm >+++ b/Koha/RefundLostItemFeeRule.pm >@@ -42,22 +42,4 @@ sub _type { > return 'RefundLostItemFeeRule'; > } > >-=head3 delete >- >-This is an overloaded delete method. It throws an exception if the wildcard >-branch is passed (it can only be modified, but not deleted). >- >-=cut >- >-sub delete { >- my ($self) = @_; >- >- if ( $self->branchcode eq '*' ) { >- Koha::Exceptions::CannotDeleteDefault->throw; >- } >- >- return $self->SUPER::delete($self); >-} >- >- > 1; >diff --git a/Koha/RefundLostItemFeeRules.pm b/Koha/RefundLostItemFeeRules.pm >index 3e37f43..479f55e 100644 >--- a/Koha/RefundLostItemFeeRules.pm >+++ b/Koha/RefundLostItemFeeRules.pm >@@ -130,14 +130,18 @@ sub _choose_branch { > =head3 _default_rule (internal) > > This function returns the default rule defined for refunding lost >-item fees on return. >+item fees on return. It defaults to 1 if no rule is defined. > > =cut > > sub _default_rule { >+ > my $self = shift; >+ my $default_rule = $self->find({ branchcode => '*' }); > >- return $self->find({ branchcode => '*' })->refund; >+ return (defined $default_rule) >+ ? $default_rule->refund >+ : 1; > } > > 1; >diff --git a/installer/data/mysql/mandatory/refund_lost_item_fee_rules.sql b/installer/data/mysql/mandatory/refund_lost_item_fee_rules.sql >deleted file mode 100644 >index 3139805..0000000 >--- a/installer/data/mysql/mandatory/refund_lost_item_fee_rules.sql >+++ /dev/null >@@ -1,2 +0,0 @@ >--- Default refund lost item fee rule >-INSERT INTO refund_lost_item_fee_rules (branchcode,refund) VALUES ( '*', '1' ); >diff --git a/t/db_dependent/RefundLostItemFeeRule.t b/t/db_dependent/RefundLostItemFeeRule.t >index 68746e3..2a8a759 100755 >--- a/t/db_dependent/RefundLostItemFeeRule.t >+++ b/t/db_dependent/RefundLostItemFeeRule.t >@@ -35,7 +35,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'Koha::RefundLostItemFeeRule::delete() tests' => sub { > >- plan tests => 7; >+ plan tests => 5; > > # Start transaction > $schema->storage->txn_begin; >@@ -68,21 +68,13 @@ subtest 'Koha::RefundLostItemFeeRule::delete() tests' => sub { > $other_rule->delete; > ok( !$other_rule->in_storage, 'Other rule deleted from storage' ); > >- # deleting the default rule >- eval { >- $default_rule->delete; >- }; >- is( ref($@), 'Koha::Exceptions::CannotDeleteDefault', >- 'Exception on deleting default' ); >- ok( $default_rule->in_storage, 'Default rule still in storage' ); >- > # Rollback transaction > $schema->storage->txn_rollback; > }; > > subtest 'Koha::RefundLostItemFeeRules::_default_rule() tests' => sub { > >- plan tests => 4; >+ plan tests => 6; > > # Start transaction > $schema->storage->txn_begin; >@@ -115,6 +107,11 @@ subtest 'Koha::RefundLostItemFeeRules::_default_rule() tests' => sub { > branchcode => '*' }); > ok( !Koha::RefundLostItemFeeRules->_default_rule, 'Default rule is set to not refund' ); > >+ $default_rule->delete; >+ ok( !$default_rule->in_storage, 'Default rule effectively deleted from storage' ); >+ >+ ok( Koha::RefundLostItemFeeRules->_default_rule, 'Default rule is set to refund if no default rule is present' ); >+ > # Rollback transaction > $schema->storage->txn_rollback; > }; >-- >2.8.1
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 14048
:
52016
|
52017
|
52018
|
52019
|
52020
|
52169
|
52170
|
52202
|
52203
|
52286
|
52287
|
52288
|
52289
|
52290
|
52291
|
52292
|
52293
|
52306
|
52444
|
52445
|
52446
|
52447
|
52448
|
52449
|
52450
|
52451
|
52482
|
52658
|
52659
|
52660
|
52661
|
52662
|
52663
|
52664
|
52665
|
52666
|
52667
|
52668
|
52748
|
52749
|
52750
|
52751
|
52752
|
52753
|
52754
|
52755
|
52756
|
52757
|
52835
|
52836
|
52837
|
52838
|
52839
|
52840
|
52841
|
52842
|
52843
|
52844
|
52876
|
52883
|
52894
|
53017
|
53018
|
53019
|
53020
|
53021
|
53022
|
53023
|
53024
|
53025
|
53026
|
53027
|
53028
| 53029