From f8751b002c218f273e9eaf69469e7266694bb7f7 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Fri, 9 Dec 2016 19:52:17 +0000 Subject: [PATCH] fix(subs): record creation for gifts --- test/api/v3/unit/libs/payments.test.js | 8 ++++++++ website/server/libs/payments.js | 1 + 2 files changed, 9 insertions(+) diff --git a/test/api/v3/unit/libs/payments.test.js b/test/api/v3/unit/libs/payments.test.js index e71e15dea5..fcb6cd82dd 100644 --- a/test/api/v3/unit/libs/payments.test.js +++ b/test/api/v3/unit/libs/payments.test.js @@ -145,6 +145,14 @@ describe('payments/index', () => { expect(recipient.purchased.plan.dateUpdated).to.exist; }); + it('sets plan.dateCreated if it did not previously exist', async () => { + expect(recipient.purchased.plan.dateCreated).to.not.exist; + + await api.createSubscription(data); + + expect(recipient.purchased.plan.dateCreated).to.exist; + }); + it('does not change plan.customerId if it already exists', async () => { recipient.purchased.plan = plan; data.customerId = 'purchaserCustomerId'; diff --git a/website/server/libs/payments.js b/website/server/libs/payments.js index 26de9828c6..65cfb960a4 100644 --- a/website/server/libs/payments.js +++ b/website/server/libs/payments.js @@ -80,6 +80,7 @@ api.createSubscription = async function createSubscription (data) { plan.dateTerminated = moment(plan.dateTerminated).add({months}).toDate(); } else { plan.dateTerminated = moment().add({months}).toDate(); + plan.dateCreated = today; } }