Skip to content

Commit 4331abc

Browse files
committed
feat: return products if requested even if phases are not listed in fields
1 parent da40ec6 commit 4331abc

File tree

3 files changed

+1
-48
lines changed

3 files changed

+1
-48
lines changed

src/routes/projects/get.spec.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -610,27 +610,6 @@ describe('GET Project', () => {
610610
}
611611
});
612612
});
613-
614-
it('should not return "phases.products.name" field, when it\'s defined in "fields" query param but "phases" is not defined', (done) => {
615-
request(server)
616-
617-
.get(`/v5/projects/${project1.id}?fields=id,phases.products.name`)
618-
.set({
619-
Authorization: `Bearer ${testUtil.jwts.admin}`,
620-
})
621-
.expect('Content-Type', /json/)
622-
.expect(200)
623-
.end((err, res) => {
624-
if (err) {
625-
done(err);
626-
} else {
627-
const resJson = res.body;
628-
should.exist(resJson);
629-
resJson.should.not.have.property('phases');
630-
done();
631-
}
632-
});
633-
});
634613
});
635614
});
636615
});

src/routes/projects/list.spec.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,27 +1244,6 @@ describe('LIST Project', () => {
12441244
}
12451245
});
12461246
});
1247-
1248-
it('should not return "phases.products.name" field, when it\'s defined in "fields" query param but "phases" is not defined', (done) => {
1249-
request(server)
1250-
.get('/v5/projects/?fields=phases.products.name')
1251-
.set({
1252-
Authorization: `Bearer ${testUtil.jwts.admin}`,
1253-
})
1254-
.expect('Content-Type', /json/)
1255-
.expect(200)
1256-
.end((err, res) => {
1257-
if (err) {
1258-
done(err);
1259-
} else {
1260-
const resJson = res.body;
1261-
should.exist(resJson);
1262-
const project = _.find(resJson, p => p.id === 1);
1263-
project.should.not.have.property('phases');
1264-
done();
1265-
}
1266-
});
1267-
});
12681247
});
12691248
});
12701249
});

src/util.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,7 @@ _.assignIn(util, {
256256
}
257257

258258
if (allowedFields.project_phases_products) {
259-
if (fields.project_phases.length > 0) {
260-
parseSubFields('project_phases_products', 'phases.products');
261-
} else {
262-
// if donot have 'phases', so hide 'phases.products'
263-
fields.project_phases_products = [];
264-
}
259+
parseSubFields('project_phases_products', 'phases.products');
265260
}
266261
}
267262
return fields;

0 commit comments

Comments
 (0)