fix: Fixing xml data export 500 error. (#10114)

* fix: Fixing xml data export 500 error.

fixes #10100

* Removing outdated comment.

* Making xml data export test pass consistently.
This commit is contained in:
Travis
2018-03-17 14:24:40 -07:00
committed by Matteo Pagliazzi
parent e43749bed1
commit d4e2f5ac9e
2 changed files with 15 additions and 6 deletions

View File

@@ -7,8 +7,7 @@ import util from 'util';
let parseStringAsync = util.promisify(xml2js.parseString).bind(xml2js); let parseStringAsync = util.promisify(xml2js.parseString).bind(xml2js);
describe('GET /export/userdata.xml', () => { describe('GET /export/userdata.xml', () => {
// TODO disabled because it randomly causes the build to fail it('should return a valid XML file with user data', async () => {
xit('should return a valid XML file with user data', async () => {
let user = await generateUser(); let user = await generateUser();
let tasks = await user.post('/tasks/user', [ let tasks = await user.post('/tasks/user', [
{type: 'habit', text: 'habit 1'}, {type: 'habit', text: 'habit 1'},
@@ -31,13 +30,21 @@ describe('GET /export/userdata.xml', () => {
expect(res).to.contain.all.keys(['tasks', 'flags', 'tasksOrder', 'auth']); expect(res).to.contain.all.keys(['tasks', 'flags', 'tasksOrder', 'auth']);
expect(res.auth.local).not.to.have.keys(['salt', 'hashed_password']); expect(res.auth.local).not.to.have.keys(['salt', 'hashed_password']);
expect(res.tasks).to.have.all.keys(['dailys', 'habits', 'todos', 'rewards']); expect(res.tasks).to.have.all.keys(['dailys', 'habits', 'todos', 'rewards']);
expect(res.tasks.habits.length).to.equal(2); expect(res.tasks.habits.length).to.equal(2);
expect(res.tasks.habits[0]._id).to.equal(tasks[0]._id); let habitIds = _.map(res.tasks.habits, '_id');
expect(habitIds).to.have.deep.members([tasks[0]._id, tasks[4]._id]);
expect(res.tasks.dailys.length).to.equal(2); expect(res.tasks.dailys.length).to.equal(2);
expect(res.tasks.dailys[0]._id).to.equal(tasks[1]._id); let dailyIds = _.map(res.tasks.dailys, '_id');
expect(dailyIds).to.have.deep.members([tasks[1]._id, tasks[5]._id]);
expect(res.tasks.rewards.length).to.equal(2); expect(res.tasks.rewards.length).to.equal(2);
expect(res.tasks.rewards[0]._id).to.equal(tasks[2]._id); let rewardIds = _.map(res.tasks.rewards, '_id');
expect(rewardIds).to.have.deep.members([tasks[2]._id, tasks[6]._id]);
expect(res.tasks.todos.length).to.equal(3); expect(res.tasks.todos.length).to.equal(3);
expect(res.tasks.todos[1]._id).to.equal(tasks[3]._id); let todoIds = _.map(res.tasks.todos, '_id');
expect(todoIds).to.deep.include.members([tasks[3]._id, tasks[7]._id]);
}); });
}); });

View File

@@ -584,11 +584,13 @@ let schema = new Schema({
// Items manually pinned by the user // Items manually pinned by the user
pinnedItems: [{ pinnedItems: [{
_id: false,
path: {type: String}, path: {type: String},
type: {type: String}, type: {type: String},
}], }],
// Items the user manually unpinned from the ones suggested by Habitica // Items the user manually unpinned from the ones suggested by Habitica
unpinnedItems: [{ unpinnedItems: [{
_id: false,
path: {type: String}, path: {type: String},
type: {type: String}, type: {type: String},
}], }],