make sure user.tasksOrder is update only when necessary

This commit is contained in:
Matteo Pagliazzi
2016-01-02 17:46:31 +01:00
parent 7490bfae87
commit 743f98d67d
2 changed files with 28 additions and 1 deletions

View File

@@ -54,6 +54,21 @@ describe('POST /tasks', () => {
});
});
it('does not update user.tasksOrder.{taskType} when the task is not saved because invalid', async () => {
let originalHabitsOrder = (await user.get('/user')).tasksOrder.habits;
return expect(user.post('/tasks', {
type: 'habit',
})).to.eventually.be.rejected.and.eql({ // this block is necessary
code: 400,
error: 'BadRequest',
message: 'habit validation failed',
}).then(async () => {
let updatedHabitsOrder = (await user.get('/user')).tasksOrder.habits;
expect(updatedHabitsOrder).to.eql(originalHabitsOrder);
});
});
it('automatically sets "task.userId" to user\'s uuid', async () => {
let task = await user.post('/tasks', {
text: 'test habit',