foodsoft/spec/models/delivery_spec.rb
Philipp Rothmann c6560e0cea Add additional model and integration tests
This commit adds new tests for a better coverage.

integration/
  * home
  * supplier

models/
  * article
  * delivery
  * group_order_article
  * supplier

also adds a new factory for delivery

Co-authored-by: viehlieb <pf@pragma-shift.net>
Co-authored-by: Tobias Kneuker <tk@pragma-shift.net>
2022-11-27 12:39:57 +01:00

23 lines
578 B
Ruby

require_relative '../spec_helper'
describe Delivery do
let(:delivery) { create :delivery }
let(:stock_article) { create :stock_article, price: 3 }
it 'creates new stock_changes' do
delivery.new_stock_changes = ([
{
quantity: 1,
stock_article: stock_article
},
{
quantity: 2,
stock_article: stock_article
}
])
expect(delivery.stock_changes.last[:stock_article_id]).to be stock_article.id
expect(delivery.includes_article?(stock_article)).to be true
expect(delivery.sum(:net)).to eq 9
end
end