From 60b0e7a23f6032f072fb28481df958a915375630 Mon Sep 17 00:00:00 2001 From: tvpeter Date: Tue, 10 Sep 2019 13:35:41 +0100 Subject: [PATCH] Refactor user requests details [Finishes #168399455] --- src/controllers/Trip.js | 7 +++++-- test/trip.test.js | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/controllers/Trip.js b/src/controllers/Trip.js index ea35dc5..6785b8b 100644 --- a/src/controllers/Trip.js +++ b/src/controllers/Trip.js @@ -20,12 +20,15 @@ class TripController { try { const userTrips = await Trip.findAll({ where: { userId: id }, + attributes: { + exclude: ['startBranchId', 'userId'] + }, include: [ { model: Stop, as: 'stop', - attributes: ['destinationBranchId', 'accomodationId'], - include: [{ model: Branch, as: 'branch', attributes: ['id', 'name', 'locationId'] }, + attributes: ['id'], + include: [{ model: Branch, as: 'branch', attributes: ['id', 'name'] }, { model: Accomodation, as: 'accomodation', attributes: ['id', 'name', 'capacity', 'status'] }] }, { model: User, as: 'user', attributes: ['firstName', 'lastName'] }, diff --git a/test/trip.test.js b/test/trip.test.js index 143c9aa..7a22b11 100644 --- a/test/trip.test.js +++ b/test/trip.test.js @@ -44,8 +44,7 @@ describe('Travel Request', () => { chai.request(app).get(`${baseURL}/user`).send({ token }).end((err, res) => { expect(res.status).to.eq(200); expect(res.body.message).to.eq('User requests successfully retrieved'); - expect(res.body.data[0].userId).to.eq(completeLoginWithCode.id); - expect(res.body.data[0].stop).to.be.an('Array'); + expect(res.body.data).to.be.an('Array'); done(); }); });