diff --git a/app/controllers/concerns/lending.rb b/app/controllers/concerns/lending.rb index 0750cf3ea..00a82dde9 100644 --- a/app/controllers/concerns/lending.rb +++ b/app/controllers/concerns/lending.rb @@ -54,7 +54,7 @@ def undo_loan(loan) loan.item.increment_quantity end end - return true + true end def restore_loan(loan) diff --git a/test/controllers/concerns/lending_test.rb b/test/controllers/concerns/lending_test.rb index c5e32a822..3d7e2ff2b 100644 --- a/test/controllers/concerns/lending_test.rb +++ b/test/controllers/concerns/lending_test.rb @@ -234,6 +234,18 @@ class LendingTest < ActiveSupport::TestCase assert_equal 10, item.quantity end + test "destroy loan after undoing" do + borrow_policy = create(:default_borrow_policy) + item = create(:item, quantity: 1, borrow_policy: borrow_policy) + member = create(:verified_member) + + loan = create_loan(item, member) + assert !member.checked_out_loans.empty? + + assert undo_loan(loan) + assert member.checked_out_loans.empty? + end + test "marks the item as retired when the quantity hits 0" do borrow_policy = create(:consumable_borrow_policy) item = create(:item, quantity: 1, borrow_policy: borrow_policy)