Skip to content

Commit

Permalink
Add a test for returning items.
Browse files Browse the repository at this point in the history
  • Loading branch information
jim committed Nov 19, 2024
1 parent c5dce61 commit 31b2c6a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</th>
</tr>
<% reservation_hold.reservation_loans.each do |reservation_loan| %>
<tr>
<tr id="<%= dom_id(reservation_loan) %>">
<% if reservation_loan.quantity %>
<td><%= reservation_hold.item_pool.name %></td>
<td><%= reservation_loan.quantity %></td>
Expand Down
41 changes: 35 additions & 6 deletions test/system/admin/reservations/reservations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,40 @@ def assert_hold_quantity(item_pool, quantity)
end
end

# test "returning items" do
# hammer_pool = create(:item_pool, name: "Hammer")
# hammer = create(:reservable_item, item_pool: hammer_pool)
test "returning items" do
hammer_pool = create(:item_pool, name: "Hammer")
hammer = create(:reservable_item, item_pool: hammer_pool)
glove_pool = create(:item_pool, name: "Gloves", uniquely_numbered: false, unnumbered_count: 10)

reservation = create(:reservation, :borrowed)

hammer_hold = create(:reservation_hold, item_pool: hammer_pool, reservation:)
hammer_loan = reservation.reservation_loans.create!(reservation_hold: hammer_hold, reservable_item: hammer)
glove_hold = create(:reservation_hold, item_pool: glove_pool, quantity: 2, reservation:)
glove_loan = reservation.reservation_loans.create!(reservation_hold: glove_hold, quantity: 2)

visit admin_reservation_loans_path(reservation)

within_dom_id(hammer_loan) do
refute_text "returned"
end

# reservation = create(:reservation, :borrowed)
# visit admin_reservation_loans_path(reservation)
# end
# return hammer
fill_in "Item ID", with: hammer.id
click_on "Return Item"

within_dom_id(hammer_loan) do
assert_text "returned"
end

# return gloves
within_dom_id(glove_loan) do
refute_text "returned"
click_on "Return all"
assert_text "returned"
end

assert hammer_loan.reload.checked_in_at
assert glove_loan.reload.checked_in_at
end
end

0 comments on commit 31b2c6a

Please sign in to comment.