diff --git a/ghost/members-importer/lib/importer.js b/ghost/members-importer/lib/importer.js index ed00c8c54a..74990f36d1 100644 --- a/ghost/members-importer/lib/importer.js +++ b/ghost/members-importer/lib/importer.js @@ -161,7 +161,7 @@ module.exports = class MembersCSVImporter { }, options); } else if (row.complimentary_plan) { await membersRepository.update({ - products: [{id: defaultTier.id}] + products: [{id: defaultTier.id.toString()}] }, { ...options, id: member.id diff --git a/ghost/members-importer/test/importer.test.js b/ghost/members-importer/test/importer.test.js index 14ff8f3b78..b9e0b0e6a6 100644 --- a/ghost/members-importer/test/importer.test.js +++ b/ghost/members-importer/test/importer.test.js @@ -2,6 +2,8 @@ // const testUtils = require('./utils'); require('./utils'); +const Tier = require('@tryghost/tiers/lib/Tier'); +const ObjectID = require('bson-objectid').default; const assert = require('assert'); const fs = require('fs-extra'); const path = require('path'); @@ -16,6 +18,7 @@ describe('Importer', function () { let knexStub; let sendEmailStub; let membersRepositoryStub; + let defaultTierId; const defaultAllowedFields = { email: 'email', @@ -43,9 +46,10 @@ describe('Importer', function () { }); const buildMockImporterInstance = () => { - const defaultTierDummy = { - id: 'default_tier_id' - }; + defaultTierId = new ObjectID(); + const defaultTierDummy = new Tier({ + id: defaultTierId + }); memberCreateStub = sinon.stub().resolves({ id: `test_member_id` @@ -200,7 +204,7 @@ describe('Importer', function () { // complimentary_plan import membersRepositoryStub.update.calledOnce.should.be.true(); should.deepEqual(membersRepositoryStub.update.args[0][0].products, [{ - id: 'default_tier_id' + id: defaultTierId.toString() }]); should.deepEqual(membersRepositoryStub.update.args[0][1].id, 'test_member_id'); });