Skip to content

Commit

Permalink
add test for non-consumable loan and standardrb fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rendonluis committed Oct 17, 2023
1 parent 154b365 commit f5d3913
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/concerns/lending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def undo_loan(loan)
loan.item.increment_quantity
end
end
return true
true
end

def restore_loan(loan)
Expand Down
12 changes: 12 additions & 0 deletions test/controllers/concerns/lending_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f5d3913

Please sign in to comment.