diff --git a/test/api/unit/libs/payments/payments.test.js b/test/api/unit/libs/payments/payments.test.js index e9fdd3b90f..75500e28f5 100644 --- a/test/api/unit/libs/payments/payments.test.js +++ b/test/api/unit/libs/payments/payments.test.js @@ -12,7 +12,7 @@ import { } from '../../../../helpers/api-unit.helper'; import * as worldState from '../../../../../website/server/libs/worldState'; -describe.only('payments/index', () => { +describe('payments/index', () => { let user; let group; let data; let plan; diff --git a/website/server/libs/payments/subscriptions.js b/website/server/libs/payments/subscriptions.js index 11dd5768c1..f478317e12 100644 --- a/website/server/libs/payments/subscriptions.js +++ b/website/server/libs/payments/subscriptions.js @@ -70,8 +70,15 @@ async function createSubscription (data) { ? data.gift.subscription.key : data.sub.key]; const autoRenews = data.autoRenews !== undefined ? data.autoRenews : true; - const updatedFrom = data.updatedFrom ? shared.content.subscriptionBlocks[data.updatedFrom.key] : undefined; - const months = updatedFrom && Number(updatedFrom.months) !== 1 ? Math.max(0, Number(block.months) - Number(updatedFrom.months)) : Number(block.months); + const updatedFrom = data.updatedFrom + ? shared.content.subscriptionBlocks[data.updatedFrom.key] + : undefined; + let months; + if (updatedFrom && Number(updatedFrom.months) !== 1) { + months = Math.max(0, Number(block.months) - Number(updatedFrom.months)); + } else { + months = Number(block.months); + } const today = new Date(); let group; let groupId;