add optional created_by record to the doc

This commit is contained in:
2016-05-16 15:01:36 -07:00
parent 31159baae9
commit 8d21dc6967
3 changed files with 23 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ Client.prototype.get = function (params = {}, source = {}) {
const _source = Object.assign({
jobtype: 'jobtype',
created_by: null,
payload: {
id: 'sample-job-1',
now: 'Mon Apr 25 2016 14:13:04 GMT-0700 (MST)'

View File

@@ -14,6 +14,7 @@ const Job = module;
const maxPriority = 20;
const minPriority = -20;
const defaultPriority = 10;
const defaultCreatedBy = null;
describe('Job Class', function () {
let client;
@@ -90,6 +91,24 @@ describe('Job Class', function () {
});
});
it('should index the created_by value', function () {
const createdBy = 'user_identifier';
const job = new Job(client, index, type, payload, Object.assign({ created_by: createdBy }, options));
return job.ready.then(() => {
const newDoc = validateDoc(client.index);
expect(newDoc.body).to.have.property('created_by', createdBy);
});
});
it('should index default created_by value', function () {
const job = new Job(client, index, type, payload, options);
return job.ready.then(() => {
const newDoc = validateDoc(client.index);
expect(newDoc.body).to.have.property('created_by', defaultCreatedBy);
});
});
it('should index timeout value from options', function () {
const job = new Job(client, index, type, payload, options);
return job.ready.then(() => {