Fix subscriptions ending early - fixes #8600 (#8746)

* Use “now” for calculation of the subscription end date instead of plan.dateUpdated

* add test to show previously incorrect logic does not affect sub end date.
This commit is contained in:
joe-salomon
2017-06-07 10:16:55 -07:00
committed by Sabe Jones
parent befacca457
commit 2292ba2694
2 changed files with 13 additions and 1 deletions

View File

@@ -504,6 +504,18 @@ describe('payments/index', () => {
expect(daysTillTermination).to.be.within(13, 15);
});
it('terminates at next billing date even if dateUpdated is prior to now', async () => {
data.nextBill = moment().add({ days: 15 });
data.user.purchased.plan.dateUpdated = moment().subtract({ days: 10 });
await api.cancelSubscription(data);
let now = new Date();
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
expect(daysTillTermination).to.be.within(13, 15);
});
it('resets plan.extraMonths', async () => {
user.purchased.plan.extraMonths = 5;