0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

🐛 Fixed error on saving member with susbcriptions

closes https://github.com/TryGhost/Team/issues/699

With custom products, saving a member with subscriptions on member detail page in Admin throws errors on console, though the save is successful. This breaks the Admin as user needs to refresh the screen again to get rid of error. This change -

- updates the response on member save to return `price` object in subscription
- updates tests
This commit is contained in:
Rishabh 2021-05-19 22:32:15 +05:30
parent 0e77b378a6
commit a4c78dbf19
2 changed files with 42 additions and 1 deletions

View file

@ -200,7 +200,7 @@ module.exports = {
await member.load(['stripeSubscriptions']);
}
await member.load(['stripeSubscriptions.customer']);
await member.load(['stripeSubscriptions.customer', 'stripeSubscriptions.stripePrice', 'stripeSubscriptions.stripePrice.stripeProduct']);
return member;
} catch (error) {

View file

@ -206,6 +206,47 @@ describe('Members API (canary)', function () {
});
});
it('Paid members subscriptions has price data', function () {
const memberChanged = {
name: 'Updated name'
};
return request
.get(localUtils.API.getApiQuery('members/?search=egon&paid=true'))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.then((res) => {
should.not.exist(res.headers['x-cache-invalidate']);
const jsonResponse = res.body;
should.exist(jsonResponse);
should.exist(jsonResponse.members);
jsonResponse.members.should.have.length(1);
should.exist(jsonResponse.members[0].subscriptions[0].price);
return jsonResponse.members[0];
}).then((paidMember) => {
return request
.put(localUtils.API.getApiQuery(`members/${paidMember.id}/`))
.send({members: [memberChanged]})
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.then((res) => {
should.not.exist(res.headers['x-cache-invalidate']);
const jsonResponse = res.body;
should.exist(jsonResponse);
should.exist(jsonResponse.members);
jsonResponse.members.should.have.length(1);
localUtils.API.checkResponse(jsonResponse.members[0], 'member', ['subscriptions', 'products']);
should.exist(jsonResponse.members[0].subscriptions[0].price);
jsonResponse.members[0].name.should.equal(memberChanged.name);
});
});
});
it('Add should fail when passing incorrect email_type query parameter', function () {
const member = {
name: 'test',