delivery: add delivery test
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
a71ca3c2dc
commit
75b0bdf856
2 changed files with 32 additions and 0 deletions
9
spec/factories/delivery.rb
Normal file
9
spec/factories/delivery.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require 'factory_bot'
|
||||
|
||||
FactoryBot.define do
|
||||
factory :delivery do
|
||||
supplier { create :supplier }
|
||||
invoice { create :invoice }
|
||||
date { Faker::Date.backward(days: 14) }
|
||||
end
|
||||
end
|
23
spec/models/delivery_spec.rb
Normal file
23
spec/models/delivery_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
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
|
Loading…
Reference in a new issue