do not store GroupOrderArticles with zero quantity and tolerance
This commit is contained in:
parent
ce0ee6773a
commit
25854f2de7
4 changed files with 22 additions and 7 deletions
|
|
@ -22,15 +22,16 @@ describe 'receiving an order', :type => :feature do
|
|||
|
||||
# reload all group_order_articles
|
||||
def reload_articles
|
||||
[goa1, goa2].map(&:reload)
|
||||
goa1.reload unless goa1.destroyed?
|
||||
goa2.reload unless goa2.destroyed?
|
||||
oa.reload
|
||||
end
|
||||
|
||||
def check_quantities(units, q1, q2)
|
||||
reload_articles
|
||||
expect(oa.units).to eq units
|
||||
expect(goa1.result).to be_within(1e-3).of q1
|
||||
expect(goa2.result).to be_within(1e-3).of q2
|
||||
expect(goa1.destroyed? ? 0 : goa1.result).to be_within(1e-3).of q1
|
||||
expect(goa2.destroyed? ? 0 : goa2.result).to be_within(1e-3).of q2
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ describe GroupOrderArticle do
|
|||
it 'has zero quantity by default' do expect(goa.quantity).to eq(0) end
|
||||
it 'has zero tolerance by default' do expect(goa.tolerance).to eq(0) end
|
||||
it 'has zero result by default' do expect(goa.result).to eq(0) end
|
||||
it 'is not ordered by default' do expect(GroupOrderArticle.ordered.where(:id => goa.id).exists?).to be_false end
|
||||
it 'has zero total price by default' do expect(goa.total_price).to eq(0) end
|
||||
|
||||
describe do
|
||||
|
|
@ -39,8 +38,7 @@ describe GroupOrderArticle do
|
|||
it 'can unorder a product' do
|
||||
goa.update_quantities(rand(1..99), rand(0..99))
|
||||
goa.update_quantities(0, 0)
|
||||
expect(goa.quantity).to eq(0)
|
||||
expect(goa.tolerance).to eq(0)
|
||||
expect(GroupOrderArticle.exists?(goa.id)).to be_false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue