Resolved two more edge cases in quota handling

Scenario 1) Blocking voucher is used in a CartPosition. Previously
too much was subtracted from the quota.

Scenario 2) When two quotas are assigned to a product and one of them
is sold out, blocking vouchers for the other quota should not enable to
buy the product.
This commit is contained in:
Raphael Michel
2016-08-15 22:53:32 +02:00
parent fddd612a63
commit 63b683096b
5 changed files with 132 additions and 1 deletions

View File

@@ -600,6 +600,15 @@ class CartTest(CartTestMixin, TestCase):
objs = list(CartPosition.objects.filter(cart_id=self.session_key, event=self.event))
self.assertEqual(len(objs), 0)
def test_voucher_quota_other_quota_full(self):
quota2 = self.event.quotas.create(name='Test', size=0)
quota2.variations.add(self.shirt_red)
v = Voucher.objects.create(quota=self.quota_shirts, event=self.event)
self.client.post('/%s/%s/cart/add' % (self.orga.slug, self.event.slug), {
'variation_%d_%d_voucher' % (self.shirt.id, self.shirt_red.id): v.code,
}, follow=True)
self.assertEqual(CartPosition.objects.filter(cart_id=self.session_key, event=self.event).count(), 0)
def test_hide_without_voucher(self):
v = Voucher.objects.create(item=self.shirt, event=self.event)
self.shirt.hide_without_voucher = True