0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added automatic 'first_name' column mapping for members CSV importer

no issue

- When columns which match /name/ patter are present in imported CSV they should detect the mapping to 'name' column automatically
This commit is contained in:
Nazar Gargol 2020-08-20 15:04:35 +12:00
parent c47593891c
commit 240edf89aa
2 changed files with 20 additions and 0 deletions

View file

@ -172,6 +172,11 @@ export default Service.extend({
continue;
}
if (!mapping.name && /name/.test(key)) {
mapping.name = key;
continue;
}
if (!mapping[key] && supportedTypes.includes(key) && !(autoDetectedTypes.includes(key))) {
mapping[key] = key;
}

View file

@ -58,6 +58,7 @@ describe('Integration: Service: member-import-validator', function () {
expect(validationErrors.length).to.equal(1);
expect(validationErrors[0].message).to.equal('Missing Stripe connection');
expect(mapping.name).to.equal('name');
expect(mapping.email).to.equal('email');
expect(mapping.stripe_customer_id).to.equal('stripe_customer_id');
});
@ -206,5 +207,19 @@ describe('Integration: Service: member-import-validator', function () {
expect(result.email).to.equal('correo_electronico');
expect(result.stripe_customer_id).to.equal('stripe_id');
});
it('correctly detects variation of "name" mapping', async function () {
this.owner.register('service:membersUtils', Service.extend({
isStripeEnabled: false
}));
let service = this.owner.lookup('service:member-import-validator');
const result = service._detectDataTypes([{
first_name: 'Rish'
}]);
expect(result.name).to.equal('first_name');
});
});
});