mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
🐛 Fixed member responses not including complimentary subs when canceled subs exist
refs https://github.com/TryGhost/Team/issues/1141 - when a member had canceled subscriptions the check we have to match products to subscriptions to determine whether to insert the hardcoded complimentary subscription was incorrectly matching against the canceled subscriptions - updated to match only active subscriptions
This commit is contained in:
parent
e1d6fc4ed4
commit
e8b8fef985
2 changed files with 5 additions and 2 deletions
|
@ -51,7 +51,10 @@ module.exports = class MemberBREADService {
|
|||
return member;
|
||||
}
|
||||
|
||||
const subscriptionProducts = (member.subscriptions || []).map(sub => sub.price.product.product_id);
|
||||
const subscriptionProducts = (member.subscriptions || [])
|
||||
.filter(sub => sub.status !== 'canceled')
|
||||
.map(sub => sub.price.product.product_id);
|
||||
|
||||
for (const product of member.products) {
|
||||
if (!subscriptionProducts.includes(product.id)) {
|
||||
const productAddEvent = member.productEvents.find(event => event.product_id === product.id);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const MemberRepository = require('../../../../lib/repositories/member');
|
||||
|
||||
describe('MemberRepository', function () {
|
||||
describe('#isComplimentarySubscriptio', function () {
|
||||
describe('#isComplimentarySubscription', function () {
|
||||
it('Does not error when subscription.plan is null', function () {
|
||||
const repo = new MemberRepository({});
|
||||
repo.isComplimentarySubscription({});
|
||||
|
|
Loading…
Add table
Reference in a new issue