mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
remove wrong test
This commit is contained in:
@@ -452,80 +452,6 @@ describe('Apple Payments', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows second user to subscribe if initial subscription is cancelled', async () => {
|
|
||||||
user.profile.name = 'sender';
|
|
||||||
user.purchased.plan.paymentMethod = applePayments.constants.PAYMENT_METHOD_APPLE;
|
|
||||||
user.purchased.plan.customerId = token;
|
|
||||||
user.purchased.plan.planId = common.content.subscriptionBlocks.basic_3mo.key;
|
|
||||||
user.purchased.plan.additionalData = receipt;
|
|
||||||
user.purchased.plan.dateTerminated = moment.utc().subtract({ day: 1 }).toDate();
|
|
||||||
await user.save();
|
|
||||||
|
|
||||||
iap.getPurchaseData.restore();
|
|
||||||
iapGetPurchaseDataStub = sinon.stub(iap, 'getPurchaseData')
|
|
||||||
.returns([{
|
|
||||||
expirationDate: moment.utc().add({ day: 3 }).toDate(),
|
|
||||||
purchaseDate: moment.utc().toDate(),
|
|
||||||
productId: sku,
|
|
||||||
transactionId: `${token}new`,
|
|
||||||
originalTransactionId: token,
|
|
||||||
}]);
|
|
||||||
|
|
||||||
const secondUser = new User();
|
|
||||||
await secondUser.save();
|
|
||||||
await applePayments.subscribe(secondUser, receipt, headers, nextPaymentProcessing);
|
|
||||||
|
|
||||||
expect(paymentsCreateSubscritionStub).to.be.calledOnce;
|
|
||||||
expect(paymentsCreateSubscritionStub).to.be.calledWith({
|
|
||||||
user: secondUser,
|
|
||||||
customerId: token,
|
|
||||||
paymentMethod: applePayments.constants.PAYMENT_METHOD_APPLE,
|
|
||||||
sub,
|
|
||||||
headers,
|
|
||||||
additionalData: receipt,
|
|
||||||
nextPaymentProcessing,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('allows second user to subscribe if multiple initial subscription are cancelled', async () => {
|
|
||||||
user.profile.name = 'sender';
|
|
||||||
user.purchased.plan.paymentMethod = applePayments.constants.PAYMENT_METHOD_APPLE;
|
|
||||||
user.purchased.plan.customerId = token;
|
|
||||||
user.purchased.plan.planId = common.content.subscriptionBlocks.basic_3mo.key;
|
|
||||||
user.purchased.plan.additionalData = receipt;
|
|
||||||
user.purchased.plan.dateTerminated = moment.utc().subtract({ day: 1 }).toDate();
|
|
||||||
await user.save();
|
|
||||||
|
|
||||||
const secondUser = new User();
|
|
||||||
secondUser.purchased.plan = user.purchased.plan;
|
|
||||||
await secondUser.save();
|
|
||||||
|
|
||||||
iap.getPurchaseData.restore();
|
|
||||||
iapGetPurchaseDataStub = sinon.stub(iap, 'getPurchaseData')
|
|
||||||
.returns([{
|
|
||||||
expirationDate: moment.utc().add({ day: 3 }).toDate(),
|
|
||||||
purchaseDate: moment.utc().toDate(),
|
|
||||||
productId: sku,
|
|
||||||
transactionId: `${token}new`,
|
|
||||||
originalTransactionId: token,
|
|
||||||
}]);
|
|
||||||
|
|
||||||
const thirdUser = new User();
|
|
||||||
await thirdUser.save();
|
|
||||||
await applePayments.subscribe(thirdUser, receipt, headers, nextPaymentProcessing);
|
|
||||||
|
|
||||||
expect(paymentsCreateSubscritionStub).to.be.calledOnce;
|
|
||||||
expect(paymentsCreateSubscritionStub).to.be.calledWith({
|
|
||||||
user: thirdUser,
|
|
||||||
customerId: token,
|
|
||||||
paymentMethod: applePayments.constants.PAYMENT_METHOD_APPLE,
|
|
||||||
sub,
|
|
||||||
headers,
|
|
||||||
additionalData: receipt,
|
|
||||||
nextPaymentProcessing,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('does not apply multiple times', async () => {
|
describe('does not apply multiple times', async () => {
|
||||||
it('errors when a user is using the same subscription', async () => {
|
it('errors when a user is using the same subscription', async () => {
|
||||||
payments.createSubscription.restore();
|
payments.createSubscription.restore();
|
||||||
|
|||||||
@@ -130,8 +130,7 @@ api.subscribe = async function subscribe (user, receipt, headers, nextPaymentPro
|
|||||||
$or: [
|
$or: [
|
||||||
{ 'purchased.plan.customerId': purchase.originalTransactionId },
|
{ 'purchased.plan.customerId': purchase.originalTransactionId },
|
||||||
{ 'purchased.plan.customerId': purchase.transactionId },
|
{ 'purchased.plan.customerId': purchase.transactionId },
|
||||||
]
|
],
|
||||||
|
|
||||||
}).exec();
|
}).exec();
|
||||||
if (existingUsers.length > 0) {
|
if (existingUsers.length > 0) {
|
||||||
if (purchase.originalTransactionId === purchase.transactionId) {
|
if (purchase.originalTransactionId === purchase.transactionId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user