From a0ebb9a6f338fd2295a041ad736de758084c1295 Mon Sep 17 00:00:00 2001 From: Fabien 'egg' O'Carroll Date: Tue, 1 Nov 2022 16:25:55 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20Tier=20description=20not?= =?UTF-8?q?=20being=20set=20=20(#15741)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes https://github.com/TryGhost/Ghost/issues/15740 The validation function for a Tier description was not returning the validated value, which meant we were unable to set the Tier description. --- ghost/core/test/e2e-api/admin/tiers.test.js | 16 ++++++++++++++++ ghost/tiers/lib/Tier.js | 1 + ghost/tiers/test/Tier.test.js | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/ghost/core/test/e2e-api/admin/tiers.test.js b/ghost/core/test/e2e-api/admin/tiers.test.js index f1a97d36ca..080887e5a6 100644 --- a/ghost/core/test/e2e-api/admin/tiers.test.js +++ b/ghost/core/test/e2e-api/admin/tiers.test.js @@ -126,4 +126,20 @@ describe('Tiers API', function () { assert(updatedTier.trial_days === 0, `The trial_days should have been set to 0`); }); + + it('Can edit description', async function () { + const {body: {tiers: [tier]}} = await agent.get('/tiers/?type:paid&limit=1'); + + await agent.put(`/tiers/${tier.id}/`) + .body({ + tiers: [{ + description: 'Updated description' + }] + }) + .expectStatus(200); + + const {body: {tiers: [updatedTier]}} = await agent.get(`/tiers/${tier.id}/`); + + assert.strictEqual('Updated description', updatedTier.description); + }); }); diff --git a/ghost/tiers/lib/Tier.js b/ghost/tiers/lib/Tier.js index 8a40c71655..6b0345c0a6 100644 --- a/ghost/tiers/lib/Tier.js +++ b/ghost/tiers/lib/Tier.js @@ -338,6 +338,7 @@ function validateDescription(value) { message: 'Tier description must be a string with a maximum of 191 characters' }); } + return value; } function validateStatus(value) { diff --git a/ghost/tiers/test/Tier.test.js b/ghost/tiers/test/Tier.test.js index 51ed7286b9..6037de7602 100644 --- a/ghost/tiers/test/Tier.test.js +++ b/ghost/tiers/test/Tier.test.js @@ -251,5 +251,13 @@ describe('Tier', function () { }); }); }); + + it('Can set the description of a Tier', async function () { + const tier = await Tier.create(validInput); + + tier.description = 'Updated description'; + + assert.strictEqual('Updated description', tier.description); + }); }); });