Add test for stock changes

This commit is contained in:
benji 2015-03-04 10:25:03 +01:00
parent ee0239447e
commit 51ba90d70a

View file

@ -0,0 +1,16 @@
require 'test_helper'
class StockTest < ActiveSupport::TestCase
test "creating and deleting orders updates stock of products" do
order = users(:benji).orders.build
order.order_items.build(product: products(:fanta), count: 2)
assert_difference "products(:fanta).stock", -2 do
order.save(validate: false)
end
assert_difference "products(:fanta).stock", +2 do
order.destroy
end
end
end