From 14c696838857938e8ecdff9d55a4864cded85a5f Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Sun, 26 Jul 2020 17:32:18 +0100 Subject: [PATCH] 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 --- core/server/api/canary/members.js | 2 ++ test/api-acceptance/admin/members_spec.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/core/server/api/canary/members.js b/core/server/api/canary/members.js index 67f019746d..d91a79970a 100644 --- a/core/server/api/canary/members.js +++ b/core/server/api/canary/members.js @@ -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(() => { diff --git a/test/api-acceptance/admin/members_spec.js b/test/api-acceptance/admin/members_spec.js index da768751cd..7a9948df87 100644 --- a/test/api-acceptance/admin/members_spec.js +++ b/test/api-acceptance/admin/members_spec.js @@ -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); + }); }); });