diff --git a/test/api/v3/integration/tasks/POST-tasks.test.js b/test/api/v3/integration/tasks/POST-tasks.test.js index d966268b68..e7e72e1389 100644 --- a/test/api/v3/integration/tasks/POST-tasks.test.js +++ b/test/api/v3/integration/tasks/POST-tasks.test.js @@ -58,8 +58,6 @@ describe('POST /tasks', () => { it('ignores setting challenge field'); - it('ignores setting value field'); - it('ignores setting completed field'); it('ignores setting streak field'); @@ -127,7 +125,7 @@ describe('POST /tasks', () => { expect(task.type).to.eql('daily'); expect(task.frequency).to.eql('daily'); expect(task.everyX).to.eql(5); - expect(task.startDate).to.eql(now); + expect(new Date(task.startDate)).to.eql(now); }); }); diff --git a/test/api/v3/integration/tasks/PUT-tasks_id.test.js b/test/api/v3/integration/tasks/PUT-tasks_id.test.js index d5e938efc5..dc7143decf 100644 --- a/test/api/v3/integration/tasks/PUT-tasks_id.test.js +++ b/test/api/v3/integration/tasks/PUT-tasks_id.test.js @@ -22,15 +22,7 @@ describe('PUT /tasks/:id', () => { // task = createdTask }); - it('returns an error if req.body.type is not valid', () => { - return expect(api.put(`/tasks/${task._id}`, { - type: 'habitF', - })).to.eventually.be.rejected.and.eql({ - code: 400, - error: 'BadRequest', - message: t('invalidReqParams'), - }); - }); + it('ignores setting type field'); it('ignores setting userId field'); @@ -57,8 +49,13 @@ describe('PUT /tasks/:id', () => { let habit; beforeEach(() => { - // create existing habit - // habit = createdHabit; + return api.post('/tasks', { + text: 'test habit', + type: 'habit', + notes: 1976, + }).then((createdHabit) => { + habit = createdHabit; + }); }); it('updates a habit', () => { @@ -80,8 +77,13 @@ describe('PUT /tasks/:id', () => { let todo; beforeEach(() => { - // create existing todo - // todo = createdTodo; + return api.post('/tasks', { + text: 'test todo', + type: 'todo', + notes: 1976, + }).then((createdTodo) => { + todo = createdTodo; + }); }); it('updates a todo', () => { @@ -101,8 +103,13 @@ describe('PUT /tasks/:id', () => { let daily; beforeEach(() => { - // create existing daily - // daily = createdDaily; + return api.post('/tasks', { + text: 'test daily', + type: 'daily', + notes: 1976, + }).then((createdDaily) => { + daily = createdDaily; + }); }); it('updates a daily', () => { @@ -134,8 +141,14 @@ describe('PUT /tasks/:id', () => { let reward; beforeEach(() => { - // create existing reward - // reward = createdReward; + return api.post('/tasks', { + text: 'test reward', + type: 'reward', + notes: 1976, + value: 10, + }).then((createdReward) => { + reward = createdReward; + }); }); it('updates a reward', () => { diff --git a/website/src/models/task.js b/website/src/models/task.js index ad9411282f..77cd0cfa2f 100644 --- a/website/src/models/task.js +++ b/website/src/models/task.js @@ -38,7 +38,9 @@ export let TaskSchema = new Schema({ }, discriminatorOptions)); TaskSchema.plugin(baseModel, { - noSet: ['challenge', 'userId', 'value', 'completed', 'history', 'streak', 'dateCompleted'], // TODO checklist fields editable? + // TODO checklist fields editable? + // TODO value should be settable only for rewards + noSet: ['challenge', 'userId', 'completed', 'history', 'streak', 'dateCompleted'], private: [], timestamps: true, });