From 8b816af1c29ce934238bf74cb259b47acab6c4ae Mon Sep 17 00:00:00 2001 From: Sumedh Nimkarde Date: Tue, 4 Dec 2018 01:15:55 +0530 Subject: [PATCH] :bug: Fixed invalid imported subscribers count (#10229) closes #9987 - Fixed the count of invalid records when importing single column csv of subscribers --- core/server/lib/fs/read-csv.js | 5 ----- core/test/functional/api/v0.1/subscribers_spec.js | 2 +- core/test/functional/api/v2/admin/subscribers_spec.js | 2 +- core/test/unit/lib/fs/read-csv_spec.js | 7 +++---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/core/server/lib/fs/read-csv.js b/core/server/lib/fs/read-csv.js index 1d52a4e882..16e1bbfb19 100644 --- a/core/server/lib/fs/read-csv.js +++ b/core/server/lib/fs/read-csv.js @@ -26,11 +26,6 @@ module.exports = function readCSV(options) { result[columnsToExtract[0].name] = value[headers[0]]; return result; }); - - // Add first row - result = {}; - result[columnsToExtract[0].name] = headers[0]; - results = [result].concat(results); } else { // If there are multiple columns in csv file // try to match headers using lookup value diff --git a/core/test/functional/api/v0.1/subscribers_spec.js b/core/test/functional/api/v0.1/subscribers_spec.js index f165ebe1df..6aa663d302 100644 --- a/core/test/functional/api/v0.1/subscribers_spec.js +++ b/core/test/functional/api/v0.1/subscribers_spec.js @@ -229,7 +229,7 @@ describe('Subscribers API', function () { jsonResponse.meta.stats.imported.should.equal(2); jsonResponse.meta.stats.duplicates.should.equal(0); - jsonResponse.meta.stats.invalid.should.equal(1); // TODO: should return 0 + jsonResponse.meta.stats.invalid.should.equal(0); }); }); }); diff --git a/core/test/functional/api/v2/admin/subscribers_spec.js b/core/test/functional/api/v2/admin/subscribers_spec.js index 7b7eb458f0..fc4e7ba28e 100644 --- a/core/test/functional/api/v2/admin/subscribers_spec.js +++ b/core/test/functional/api/v2/admin/subscribers_spec.js @@ -223,7 +223,7 @@ describe('Subscribers API', function () { jsonResponse.meta.stats.imported.should.equal(2); jsonResponse.meta.stats.duplicates.should.equal(0); - jsonResponse.meta.stats.invalid.should.equal(1); // TODO: should return 0 + jsonResponse.meta.stats.invalid.should.equal(0); }); }); }); diff --git a/core/test/unit/lib/fs/read-csv_spec.js b/core/test/unit/lib/fs/read-csv_spec.js index 9773145a99..97d2aa8043 100644 --- a/core/test/unit/lib/fs/read-csv_spec.js +++ b/core/test/unit/lib/fs/read-csv_spec.js @@ -10,10 +10,9 @@ describe('lib/fs: read csv', function () { columnsToExtract: [{name: 'email', lookup: /email/i}] }).then(function (result) { should.exist(result); - result.length.should.eql(3); - result[0].email.should.eql('email'); - result[1].email.should.eql('jbloggs@example.com'); - result[2].email.should.eql('test@example.com'); + result.length.should.eql(2); + result[0].email.should.eql('jbloggs@example.com'); + result[1].email.should.eql('test@example.com'); done(); }).catch(done); });