From d78f099d1dca793e0e422d3140ba1b78a831f565 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 4 May 2018 09:54:30 +0200 Subject: [PATCH] Bug 11943: Add unit test for double accepts Content-Type: text/plain; charset=utf-8 Test plan: Run t/db_dependent/Virtualshelves.t Signed-off-by: Marcel de Rooy --- t/db_dependent/Virtualshelves.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t index 3e42c55..8b751fe 100644 --- a/t/db_dependent/Virtualshelves.t +++ b/t/db_dependent/Virtualshelves.t @@ -90,7 +90,7 @@ subtest 'CRUD' => sub { }; subtest 'Sharing' => sub { - plan tests => 18; + plan tests => 21; my $patron_wants_to_share = $builder->build({ source => 'Borrower', }); @@ -152,6 +152,14 @@ subtest 'Sharing' => sub { $number_of_shelves_shared = Koha::Virtualshelfshares->search->count; is( $number_of_shelves_shared, 2, 'To be sure no shares have been removed' ); + # Test double accept (BZ 11943) before removing the accepted share + my $third_share = $shelf_to_share->share('valid key number 2'); + is( Koha::Virtualshelfshares->search->count, 3, 'Three shares' ); + $is_accepted = $third_share->accept( 'valid key number 2', $share_with_me->{borrowernumber} ); + is( $is_accepted->shelfnumber, $shelf_to_share->shelfnumber, 'Accept returned the existing share' ); + is( Koha::Virtualshelfshares->search->count, 2, 'Check that number of shares went down again' ); + + # Remove the first accept is( $shelf_to_share->remove_share( $share_with_me->{borrowernumber} ), 1, '1 share should have been removed if the shelf was shared with this patron' ); $number_of_shelves_shared = Koha::Virtualshelfshares->search->count; is( $number_of_shelves_shared, 1, 'To be sure the share has been removed' ); -- 2.1.4