From 9b92d79817c359635f463fd5a1e5715affe96356 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 19 Jul 2017 18:26:07 +0000 Subject: [PATCH] Bug 18572 - QA Followup Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 3 +-- opac/opac-renew.pl | 2 +- t/db_dependent/Circulation/issue.t | 13 ++++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index eab128e3c2..ead7e2b4c9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2815,7 +2815,6 @@ sub AddRenewal { my $branch = shift; my $datedue = shift; my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz)->ymd(); - my $opacrenewal = shift; my $item = GetItem($itemnumber) or return; my $item_object = Koha::Items->find( $itemnumber ); # Should replace $item @@ -2916,7 +2915,7 @@ sub AddRenewal { DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); } - unless ( $opacrenewal ) { #if from opac we are obeying OpacRenewalBranch as calculated in opac-renew.pl + unless ( C4::Context->interface eq 'opac' ) { #if from opac we are obeying OpacRenewalBranch as calculated in opac-renew.pl $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : $branch; } diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl index 580faab4a8..676012ea6f 100755 --- a/opac/opac-renew.pl +++ b/opac/opac-renew.pl @@ -82,7 +82,7 @@ else { else { $branchcode = 'OPACRenew'; } - AddRenewal( $borrowernumber, $itemnumber, $branchcode, undef, undef, 1 ); + AddRenewal( $borrowernumber, $itemnumber, $branchcode, undef, undef ); push( @renewed, $itemnumber ); } else { diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index e06882a2d7..c78c82ad91 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -216,6 +216,9 @@ is ($countaccount,1,"1 accountline has been added"); # Test AddRenewal +my $se = Test::MockModule->new( 'C4::Context' ); +$se->mock( 'interface', sub {return 'intranet'}); + # Let's renew this one at a different library for statistical purposes to test Bug 17781 C4::Context->set_userenv(@USERENV_DIFFERENT_LIBRARY); my $datedue3 = AddRenewal( $borrower_id1, $item_id1, $branchcode_1, $datedue1, $daysago10 ); @@ -230,14 +233,18 @@ like( my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 ); ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" ); +$se->mock( 'interface', sub {return 'opac'}); + #Let's do an opac renewal - whatever branchcode we send should be used -my $opac_renew_issue = $builder->build({ source=>"Issue",value=>{ +my $opac_renew_issue = $builder->build({ + source=>"Issue", + value=>{ date_due => '2017-01-01', branch => $branchcode_1, itype => $itemtype, borrowernumber => $borrower_id1 - } - }); + } +}); my $datedue4 = AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, "Stavromula", $datedue1, $daysago10, 1 ); -- 2.39.5