diff --git a/__tests__/projects.test.js b/__tests__/projects.test.js index 3029159..6f3868f 100644 --- a/__tests__/projects.test.js +++ b/__tests__/projects.test.js @@ -46,9 +46,16 @@ describe('geo-tone-backend routes', () => { it('gets all projects in the table', async () => { const user = await UserService.create(mockUser); await agent.post('/api/v1/users/sessions').send(mockUser); + await agent.post('/api/v1/profiles').send({ + userId: '2', + username: 'mockusername', + bio: 'bio', + avatar: 'url', + }); await agent.post('/api/v1/projects').send(user.userId); await agent.post('/api/v1/projects').send(user.userId); const res = await request(app).get('/api/v1/projects'); + console.log('res.body', res.body); expect(res.body).toHaveLength(3); }); diff --git a/lib/models/Project.js b/lib/models/Project.js index a712f93..5ac3887 100644 --- a/lib/models/Project.js +++ b/lib/models/Project.js @@ -15,6 +15,7 @@ module.exports = class Project { this.volume = row.volume; this.bpm = row.bpm; this.channels = row.channels; + this.avatar = row.avatar; } static async insert(userId) { @@ -36,9 +37,19 @@ module.exports = class Project { const { rows } = await pool.query( ` SELECT - * - FROM - projects + * + FROM + projects + INNER JOIN + users + ON + projects.user_id = users.user_id + INNER JOIN + profiles + ON + users.user_id = profiles.user_id + LIMIT + 25 ` ); return rows.map((row) => new Project(row));