Award mystery items at cron (#11519)

* feat(subscriber): award mystery items at cron

* fix(mystery): backfill skipped months

* fix(mystery): adjust subscriber text

* fix(mystery): correct moment logic
and remove irrelevant tests

* fix(mystery): build set one month in advance

* fix(mystery): don't add empty set to Time Travelers

* refactor(mystery): readability
This commit is contained in:
Sabe Jones
2019-11-27 12:10:56 -06:00
committed by GitHub
parent d0033322f7
commit 6395070eb6
7 changed files with 59 additions and 310 deletions

View File

@@ -439,31 +439,6 @@ describe('payments/index', () => {
fakeClock.restore();
});
it('does not awards mystery items when not within the timeframe for a mystery item', async () => {
const noMysteryItemTimeframe = 1462183920000; // May 2nd 2016
const fakeClock = sinon.useFakeTimers(noMysteryItemTimeframe);
data = { paymentMethod: 'PaymentMethod', user, sub: { key: 'basic_3mo' } };
await api.createSubscription(data);
expect(user.purchased.plan.mysteryItems).to.have.a.lengthOf(0);
fakeClock.restore();
});
it('does not add a notification for mystery items if none was awarded', async () => {
const noMysteryItemTimeframe = 1462183920000; // May 2nd 2016
const fakeClock = sinon.useFakeTimers(noMysteryItemTimeframe);
data = { paymentMethod: 'PaymentMethod', user, sub: { key: 'basic_3mo' } };
await api.createSubscription(data);
expect(user.purchased.plan.mysteryItems).to.have.a.lengthOf(0);
expect(user.notifications.find(n => n.type === 'NEW_MYSTERY_ITEMS')).to.be.undefined;
fakeClock.restore();
});
it('does not award mystery item when user already owns the item', async () => {
const mayMysteryItemTimeframe = 1464725113000; // May 31st 2016
const fakeClock = sinon.useFakeTimers(mayMysteryItemTimeframe);