From df145797b30efe74f571b0f595a211383caada02 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Mon, 24 Oct 2022 11:49:24 +0700 Subject: [PATCH] Fixed toJSON method of Tier This was returning an ObjectID object which is not a JSON primitive --- ghost/tiers/lib/Tier.js | 2 +- ghost/tiers/test/Tier.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ghost/tiers/lib/Tier.js b/ghost/tiers/lib/Tier.js index 2040c86841..8a40c71655 100644 --- a/ghost/tiers/lib/Tier.js +++ b/ghost/tiers/lib/Tier.js @@ -186,7 +186,7 @@ module.exports = class Tier { toJSON() { return { - id: this.#id, + id: this.#id.toHexString(), slug: this.#slug, name: this.#name, description: this.#description, diff --git a/ghost/tiers/test/Tier.test.js b/ghost/tiers/test/Tier.test.js index 546a9050d9..51ed7286b9 100644 --- a/ghost/tiers/test/Tier.test.js +++ b/ghost/tiers/test/Tier.test.js @@ -99,7 +99,6 @@ describe('Tier', function () { const tier = await Tier.create(validInput); const expectedProps = [ - 'id', 'slug', 'name', 'description', @@ -119,6 +118,7 @@ describe('Tier', function () { for (const prop of expectedProps) { assert(tier[prop] === tier.toJSON()[prop]); } + assert(tier.id.toHexString() === tier.toJSON().id); }); it('Errors when attempting to set invalid properties', async function () {