From e46aa8395b359c773961b1a705d4b9c7f9d3db01 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 21 Sep 2015 14:52:03 +0200 Subject: [PATCH] Bug 14368: [Follow-up] Fix workflow Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- members/discharge.pl | 3 +-- t/db_dependent/Borrower_Discharge.t | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/members/discharge.pl b/members/discharge.pl index d1a021dc72..ad8408be4c 100755 --- a/members/discharge.pl +++ b/members/discharge.pl @@ -67,9 +67,8 @@ if ( $input->param('borrowernumber') ) { # Generating discharge if needed if ( $input->param('discharge') and $can_be_discharged ) { - my $is_discharged = Koha::Borrower::Discharge::count({ + my $is_discharged = Koha::Borrower::Discharge::is_discharged({ borrowernumber => $borrowernumber, - validated => 1, }); unless ($is_discharged) { Koha::Borrower::Discharge::discharge({ diff --git a/t/db_dependent/Borrower_Discharge.t b/t/db_dependent/Borrower_Discharge.t index 97b22d729f..ce96b22126 100644 --- a/t/db_dependent/Borrower_Discharge.t +++ b/t/db_dependent/Borrower_Discharge.t @@ -1,7 +1,7 @@ #!/usr/bin/perl; use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 17; use Test::Warn; use MARC::Record; @@ -73,6 +73,12 @@ Koha::Borrower::Debarments::DelUniqueDebarment( { 'borrowernumber' => $borrower- ok( !Koha::Borrower::Debarments::IsDebarred( $borrower->{borrowernumber} ), 'The debarment has been lifted' ); ok( !Koha::Borrower::Discharge::is_discharged( { borrowernumber => $borrower->{borrowernumber} } ), 'The patron is not discharged after the restriction has been lifted' ); +# Verify that the discharge works multiple times +Koha::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} }); +is(scalar( @{ Koha::Borrower::Discharge::get_pendings() }), 1, 'There is a pending discharge request (second time)'); +Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower->{borrowernumber} } ); +is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request (second time)'); + # Check if PDF::FromHTML is installed. my $check = eval { require PDF::FromHTML; }; -- 2.39.5