diff --git a/ghost/data-generator/lib/tables/products.js b/ghost/data-generator/lib/tables/products.js index 1083a8738b..8e9c6bff41 100644 --- a/ghost/data-generator/lib/tables/products.js +++ b/ghost/data-generator/lib/tables/products.js @@ -9,13 +9,17 @@ class ProductsImporter extends TableImporter { } setImportOptions() { - this.names = ['Free Preview', 'Bronze', 'Silver', 'Gold']; + this.names = ['Free', 'Bronze', 'Silver', 'Gold']; this.count = 0; } async addStripePrices({products, stripeProducts, stripePrices}) { for (const {id} of products) { const stripeProduct = stripeProducts.find(p => id === p.product_id); + if (!stripeProduct) { + // Free product + continue; + } const monthlyPrice = stripePrices.find((p) => { return p.stripe_product_id === stripeProduct.stripe_product_id && p.interval === 'monthly'; diff --git a/ghost/data-generator/test/data-generator.test.js b/ghost/data-generator/test/data-generator.test.js index acf7241881..43916503d0 100644 --- a/ghost/data-generator/test/data-generator.test.js +++ b/ghost/data-generator/test/data-generator.test.js @@ -78,7 +78,9 @@ describe('Data Generator', function () { eventsOnly: false, knex: db, schema: schema, - logger: {}, + logger: { + info: () => {} + }, modelQuantities: { members: 10, membersLoginEvents: 5, @@ -153,12 +155,12 @@ describe('Importer', function () { const products = await productsImporter.import({amount: 1, rows: ['name', 'monthly_price', 'yearly_price']}); products.length.should.eql(1); - products[0].name.should.eql('Free Preview'); + products[0].name.should.eql('Free'); const results = await db.select('id', 'name').from('products'); results.length.should.eql(1); - results[0].name.should.eql('Free Preview'); + results[0].name.should.eql('Free'); }); it('Should import an item for each entry in an array', async function () { @@ -201,7 +203,7 @@ describe('Importer', function () { const results = await db.select('id', 'name', 'monthly_price_id', 'yearly_price_id').from('products'); results.length.should.eql(4); - results[0].name.should.eql('Free Preview'); + results[0].name.should.eql('Free'); }); });