From 64a92f1bb63bd111fd847ed08b4154ef65e894ad 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 (cherry picked from commit 132f95731124ed08f04d10a1913850d062603a09) Signed-off-by: Katrin Fischer --- 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 95ba55e019..d6eda8f9d3 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2926,7 +2926,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; @@ -3029,7 +3028,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 6435ea5435..bacc9491c6 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 17f596984f..a786d47168 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -217,6 +217,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 ); @@ -231,14 +234,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