Fixed auto-generated label not being attached to members during import

no issue

- label was being created and returned in the response OK but it was missing from the set of labels that get added to members during import
This commit is contained in:
Kevin Ansfield 2020-07-26 17:32:18 +01:00
parent 1f776e138f
commit 14c6968388
2 changed files with 17 additions and 0 deletions

View File

@ -434,6 +434,8 @@ const members = {
const name = `Import ${moment().tz(siteTimezone).format('YYYY-MM-DD HH:mm')}`;
const result = await findOrCreateLabels([{name}], frame.options);
importLabel = result[0] && result[0].toJSON();
importSetLabels.push(importLabel);
}
return Promise.resolve().then(() => {

View File

@ -339,6 +339,21 @@ describe('Members API', function () {
jsonResponse.meta.stats.imported.count.should.equal(2);
jsonResponse.meta.stats.invalid.count.should.equal(0);
jsonResponse.meta.import_label.name.should.match(/^Import \d{4}-\d{2}-\d{2} \d{2}:\d{2}$/);
return jsonResponse.meta.import_label;
}).then((importLabel) => {
// check that members had the auto-generated label attached
return request.get(localUtils.API.getApiQuery(`members/?filter=label:${importLabel.slug}`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200)
.then((res) => {
const jsonResponse = res.body;
should.exist(jsonResponse);
should.exist(jsonResponse.members);
jsonResponse.members.should.have.length(2);
});
});
});