do not exceed 99 articles when ordering in specs

This commit is contained in:
wvengen 2013-07-25 13:21:24 +02:00
parent 50f5064d8e
commit 0f01b87e3b
3 changed files with 8 additions and 4 deletions

View File

@ -24,4 +24,8 @@ FactoryGirl.define do
end
end
# requires order and article
factory :order_article do
end
end

View File

@ -13,7 +13,7 @@ FactoryGirl.define do
after :create do |supplier, evaluator|
article_count = evaluator.article_count
article_count = rand(1..100) if article_count == true
article_count = rand(1..99) if article_count == true
FactoryGirl.create_list :article, article_count, supplier: supplier
end
end

View File

@ -24,20 +24,20 @@ describe GroupOrderArticle do
end
it 'can be ordered in larger amounts' do
quantity, tolerance = rand(13..100), rand(0..100)
quantity, tolerance = rand(13..99), rand(0..99)
goa.update_quantities(quantity, tolerance)
expect(goa.quantity).to eq(quantity)
expect(goa.tolerance).to eq(tolerance)
end
it 'has a proper total price' do
quantity = rand(1..100)
quantity = rand(1..99)
goa.update_quantities(quantity, 0)
expect(goa.total_price).to eq(quantity * goa.order_article.price.fc_price)
end
it 'can unorder a product' do
goa.update_quantities(rand(1..100), rand(0..100))
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)