mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 15:38:59 +00:00
fix offset calculation
This commit is contained in:
parent
d69de2948b
commit
3f56b7fa3f
2 changed files with 17 additions and 2 deletions
|
|
@ -505,12 +505,27 @@ describe('payments/index', () => {
|
||||||
expect(user.purchased.plan.perkMonthCount).to.eql(2);
|
expect(user.purchased.plan.perkMonthCount).to.eql(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets plan.perkMonthCount to zero when creating new subscription', async () => {
|
it('sets plan.perkMonthCount to zero when creating new monthly subscription', async () => {
|
||||||
user.purchased.plan.perkMonthCount = 2;
|
user.purchased.plan.perkMonthCount = 2;
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
expect(user.purchased.plan.perkMonthCount).to.eql(0);
|
expect(user.purchased.plan.perkMonthCount).to.eql(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sets plan.perkMonthCount to zero when creating new 3 month subscription', async () => {
|
||||||
|
user.purchased.plan.perkMonthCount = 2;
|
||||||
|
await api.createSubscription(data);
|
||||||
|
expect(user.purchased.plan.perkMonthCount).to.eql(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates plan.consecutive.offset when changing subscription type', async () => {
|
||||||
|
await api.createSubscription(data);
|
||||||
|
expect(user.purchased.plan.consecutive.offset).to.eql(3);
|
||||||
|
data.sub.key = "basic_6mo";
|
||||||
|
await api.createSubscription(data);
|
||||||
|
expect(user.purchased.plan.consecutive.offset).to.eql(6);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
it('awards the Royal Purple Jackalope pet', async () => {
|
it('awards the Royal Purple Jackalope pet', async () => {
|
||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ async function createSubscription (data) {
|
||||||
// Block sub perks
|
// Block sub perks
|
||||||
if (months > 0 && (!data.gift || !isNewSubscription)) {
|
if (months > 0 && (!data.gift || !isNewSubscription)) {
|
||||||
if (!data.gift && !groupId) {
|
if (!data.gift && !groupId) {
|
||||||
plan.consecutive.offset = months;
|
plan.consecutive.offset = block.months;
|
||||||
}
|
}
|
||||||
await plan.incrementPerkCounterAndReward(recipient._id, months);
|
await plan.incrementPerkCounterAndReward(recipient._id, months);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue