Add test for stock changes
This commit is contained in:
parent
ee0239447e
commit
51ba90d70a
1 changed files with 16 additions and 0 deletions
16
test/integration/stock_test.rb
Normal file
16
test/integration/stock_test.rb
Normal 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
|
Loading…
Reference in a new issue