Fix double subscriptions, second attempt (#14345)

* fix(subscriptions): reject subs that come in too fast

* fix(lint): remove unused import

* fix(groups): individual subs may come rapidly

* fix(subscriptions): bad paren, handle rapid testing

* fix(test): reset dateUpdated between subs

* fix(test): one more block for dateUpdated

Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
Sabe Jones
2022-11-15 19:19:37 -06:00
committed by GitHub
parent 5e05190f22
commit 1a5cba57b7
3 changed files with 24 additions and 32 deletions

View File

@@ -326,9 +326,12 @@ describe('Apple Payments', () => {
it('errors when a user is already subscribed', async () => {
payments.createSubscription.restore();
user = new User();
user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
await user.save();
await applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing);
user.purchased.plan.dateUpdated = moment().subtract(1, 'hours').toDate();
await user.save();
await expect(applePayments.subscribe(sku, user, receipt, headers, nextPaymentProcessing))
.to.eventually.be.rejected.and.to.eql({