mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Removed created import labels when no records were imported
no issue - When no members are succesfully imported through CSV import process the import label should not be created. Otherwise after multiple failed attempts to import there are orphaned labels in the system
This commit is contained in:
parent
e07e0a17c6
commit
9d65de4b10
2 changed files with 16 additions and 0 deletions
|
@ -634,6 +634,11 @@ module.exports = {
|
|||
|
||||
invalid.errors = outputErrors;
|
||||
|
||||
if (imported.count === 0 && importLabel) {
|
||||
await models.Label.destroy(Object.assign({}, {id: importLabel.id}, frame.options));
|
||||
importLabel = null;
|
||||
}
|
||||
|
||||
return {
|
||||
meta: {
|
||||
stats: {
|
||||
|
@ -741,6 +746,11 @@ module.exports = {
|
|||
|
||||
invalid.errors = outputErrors;
|
||||
|
||||
if (imported.count === 0 && importLabel) {
|
||||
await models.Label.destroy(Object.assign({}, {id: importLabel.id}, frame.options));
|
||||
importLabel = null;
|
||||
}
|
||||
|
||||
return {
|
||||
meta: {
|
||||
stats: {
|
||||
|
|
|
@ -451,6 +451,8 @@ describe('Members API', function () {
|
|||
|
||||
should.equal(jsonResponse.meta.stats.invalid.errors.length, 1);
|
||||
jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Missing Stripe connection');
|
||||
|
||||
should.not.exist(jsonResponse.meta.import_label);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -485,6 +487,8 @@ describe('Members API', function () {
|
|||
|
||||
jsonResponse.meta.stats.invalid.errors[3].message.should.equal('Validation failed for \'complimentary_plan\'');
|
||||
jsonResponse.meta.stats.invalid.errors[3].count.should.equal(1);
|
||||
|
||||
should.not.exist(jsonResponse.meta.import_label);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -510,6 +514,8 @@ describe('Members API', function () {
|
|||
should.equal(jsonResponse.meta.stats.invalid.errors.length, 1);
|
||||
jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Member already exists');
|
||||
jsonResponse.meta.stats.invalid.errors[0].count.should.equal(1);
|
||||
|
||||
should.exist(jsonResponse.meta.import_label);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue