Fixed rule for import background job detection

refs https://github.com/TryGhost/Team/issues/1076

- The members CSV import would go into background job (longer running and resulting with an email) when it contained a complimentary_plan column.
- With recent members codebase decoupling Ghost does not make any connection to Stripe as "complimentary plan" data is saved purely in native data structures. Making no need for a background job for complimentary plans
This commit is contained in:
Naz 2022-10-31 16:28:21 +08:00
parent 4d26c50e0b
commit 7fe9e06c4d
No known key found for this signature in database
2 changed files with 10 additions and 1 deletions

View File

@ -87,7 +87,7 @@ module.exports = class MembersCSVImporter {
const mappedCSV = membersCSV.unparse(rows, columns);
const hasStripeData = !!(rows.find(function rowHasStripeData(row) {
return !!row.stripe_customer_id || !!row.complimentary_plan;
return !!row.stripe_customer_id;
}));
await fs.writeFile(outputFilePath, mappedCSV);

View File

@ -269,6 +269,15 @@ describe('Importer', function () {
fileContents.should.match(/^email,subscribed_to_emails,labels\r\n/);
});
it('checks for stripe data in the imported file', async function () {
const membersImporter = buildMockImporterInstance();
const result = await membersImporter.prepare(`${csvPath}/member-csv-export.csv`);
should.exist(result.metadata);
should.equal(result.metadata.hasStripeData, true);
});
});
describe('perform', function () {