From 132f95731124ed08f04d10a1913850d062603a09 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 (cherry picked from commit 9b92d79817c359635f463fd5a1e5715affe96356) Signed-off-by: Fridolin Somers --- 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 0d499d5ee2..28196a39e9 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2848,7 +2848,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 $biblio = GetBiblioFromItemNumber($itemnumber) or return; @@ -2951,7 +2950,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 90f3726588..cd2d4d8fd9 100755 --- a/opac/opac-renew.pl +++ b/opac/opac-renew.pl @@ -83,7 +83,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 a14af7c5a1..016cbb9df3 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