tap/test/integration/stock_test.rb

17 lines
425 B
Ruby
Raw Normal View History

2015-03-04 10:25:03 +01:00
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.cancel
2015-03-04 10:25:03 +01:00
end
end
end