From 83d08f1d4684cb7af106966ed8678793be7fad18 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. --- 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 d1a021d..ad8408b 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 77a6040..8e8651b 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; }; -- 1.7.10.4