diff --git a/src/bootstrap.js b/src/bootstrap.js index 5648bbc..5c6aa51 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -6,7 +6,7 @@ global.Promise = require('bluebird') Joi.rateType = () => Joi.string().valid('hourly', 'daily', 'weekly', 'monthly') Joi.jobStatus = () => Joi.string().valid('sourcing', 'in-review', 'assigned', 'closed', 'cancelled') -Joi.jobCandidateStatus = () => Joi.string().valid('open', 'selected', 'shortlist', 'rejected', 'cancelled', 'interview') +Joi.jobCandidateStatus = () => Joi.string().valid('open', 'selected', 'shortlist', 'rejected', 'cancelled', 'interview', 'topcoder-rejected') Joi.workload = () => Joi.string().valid('full-time', 'fractional') Joi.title = () => Joi.string().max(128) // Empty string is not allowed by Joi by default and must be enabled with allow(''). diff --git a/test/unit/test.js b/test/unit/test.js index b7d9db7..6f9ca67 100644 --- a/test/unit/test.js +++ b/test/unit/test.js @@ -250,10 +250,33 @@ describe('Zapier Logic Tests', () => { helper.postMessageViaWebhook.callCount.should.equal(0) }) - it('should not post to Zapier if status is changed to "selected" (not "rejected" or "shortlist")', async () => { + it('should not post to Zapier if status is changed to "interview" (not "rejected" or "shortlist")', async () => { const previousData = _.assign({}, testData.messages.JobCandidate.create.message.payload, { status: 'open', externalId: '123' }) const updateMessage = _.assign({}, testData.messages.JobCandidate.update.message, { - payload: _.assign({}, testData.messages.JobCandidate.update.message.payload, { status: 'selected', externalId: '123' }) + payload: _.assign({}, testData.messages.JobCandidate.update.message.payload, { status: 'interview', externalId: '123' }) + }) + + await testHelper.esClient.create({ + index: config.esConfig.ES_INDEX_JOB, + id: previousData.id, + body: previousData, + refresh: 'true' + }) + await testHelper.esClient.create({ + index: config.esConfig.ES_INDEX_JOB_CANDIDATE, + id: testData.messages.Job.create.message.payload.id, + body: testData.messages.Job.create.message.payload, + refresh: 'true' + }) + await services[`JobCandidateProcessorService`].processUpdate(updateMessage, transactionId) + + helper.postMessageViaWebhook.callCount.should.equal(0) + }) + + it('should not post to Zapier if status is changed to "topcoder-rejected" (not "rejected" or "shortlist")', async () => { + const previousData = _.assign({}, testData.messages.JobCandidate.create.message.payload, { status: 'open', externalId: '123' }) + const updateMessage = _.assign({}, testData.messages.JobCandidate.update.message, { + payload: _.assign({}, testData.messages.JobCandidate.update.message.payload, { status: 'topcoder-rejected', externalId: '123' }) }) await testHelper.esClient.create({