Payments gem reset (#8712)

* Added gem reset if user does not have date last updated set

* Fixed login of adding updated date
This commit is contained in:
Keith Holliday
2017-06-22 15:21:09 -06:00
committed by Sabe Jones
parent 8c8f0ea201
commit 39a112b605
2 changed files with 11 additions and 1 deletions

View File

@@ -79,6 +79,13 @@ describe('cron', () => {
expect(user.purchased.plan.gemsBought).to.equal(0);
});
it('resets plan.gemsBought on a new month if user does not have purchased.plan.dateUpdated', () => {
user.purchased.plan.gemsBought = 10;
user.purchased.plan.dateUpdated = undefined;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.gemsBought).to.equal(0);
});
it('does not reset plan.gemsBought within the month', () => {
let clock = sinon.useFakeTimers(moment().startOf('month').add(2, 'days').unix());
user.purchased.plan.dateUpdated = moment().startOf('month').toDate();