Stock validator test

This commit is contained in:
benji 2015-03-04 18:18:47 +01:00
parent 41140e0784
commit 41e8c113ed

View file

@ -0,0 +1,12 @@
require 'test_helper'
class StockValidatorTest < ActiveSupport::TestCase
test "form gives error when product out of stock" do
order = users(:benji).orders.build
order.order_items.build(product: products(:cola), count: 10)
order.save
assert_includes order.errors[:base], "There is not enough stock for your order of the following products: Cola"
end
end