Skip to content

Commit 03cd071

Browse files
committed
Add test for neg quantity in purchase line items (#5507)
1 parent e6cfb13 commit 03cd071

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

spec/models/purchase_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
expect(p).not_to be_valid
7373
end
7474

75+
it "is not valid if any line item has negative quantity" do
76+
item = create(:item)
77+
p = build(:purchase)
78+
p.line_items.build(item_id: item.id, quantity: -1)
79+
expect(p).not_to be_valid
80+
end
81+
7582
it "is valid if all categories are positive and add up to the total" do
7683
d = build(:purchase, amount_spent_in_cents: 1150,
7784
amount_spent_on_diapers_cents: 200,

0 commit comments

Comments
 (0)