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:
parent
c47593891c
commit
240edf89aa
2 changed files with 20 additions and 0 deletions
|
@ -172,6 +172,11 @@ export default Service.extend({
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mapping.name && /name/.test(key)) {
|
||||||
|
mapping.name = key;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mapping[key] && supportedTypes.includes(key) && !(autoDetectedTypes.includes(key))) {
|
if (!mapping[key] && supportedTypes.includes(key) && !(autoDetectedTypes.includes(key))) {
|
||||||
mapping[key] = key;
|
mapping[key] = key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ describe('Integration: Service: member-import-validator', function () {
|
||||||
|
|
||||||
expect(validationErrors.length).to.equal(1);
|
expect(validationErrors.length).to.equal(1);
|
||||||
expect(validationErrors[0].message).to.equal('Missing Stripe connection');
|
expect(validationErrors[0].message).to.equal('Missing Stripe connection');
|
||||||
|
expect(mapping.name).to.equal('name');
|
||||||
expect(mapping.email).to.equal('email');
|
expect(mapping.email).to.equal('email');
|
||||||
expect(mapping.stripe_customer_id).to.equal('stripe_customer_id');
|
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.email).to.equal('correo_electronico');
|
||||||
expect(result.stripe_customer_id).to.equal('stripe_id');
|
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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue