Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"messageApiUrl": "http://api.topcoder-dev.com/v5",
"busApiToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoicHJvamVjdC1zZXJ2aWNlIiwiaWF0IjoxNTEyNzQ3MDgyLCJleHAiOjE1MjEzODcwODJ9.PHuNcFDaotGAL8RhQXQMdpL8yOKXxjB5DbBIodmt7RE",
"HEALTH_CHECK_URL": "_health",
"maxPhaseProductCount": 1,
"maxPhaseProductCount": 100,
"TOKEN_CACHE_TIME": "86000",
"whitelistedOriginsForUserIdAuth": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
"EMAIL_INVITE_FROM_NAME": "Topcoder",
Expand Down
20 changes: 17 additions & 3 deletions src/routes/phases/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ const updateProjectPhaseValidation = {
order: Joi.number().integer().optional(),
}).required(),
};

const populateMemberDetails = async (phase, req) => {
const members = _.map(phase.members, member => _.pick(member, 'userId'));
try {
const detailedMembers = await util.getObjectsWithMemberDetails(members, ['userId', 'handle', 'photoURL'], req);
return _.assign(phase, { members: detailedMembers });
} catch (err) {
return _.assign(phase, { members });
}
};

module.exports = [
// validate request payload
Expand Down Expand Up @@ -102,8 +110,14 @@ module.exports = [
updatedValue,
previousValue,
ROUTES.PHASES.UPDATE);

res.json(updated);
return models.ProjectPhase.findOne({
where: { id: phaseId, projectId },
include: [{
model: models.ProjectPhaseMember,
as: 'members',
}],
}).then(phaseWithMembers => populateMemberDetails(phaseWithMembers.toJSON(), req)
.then(result => res.json(result)));
})
.catch(err => next(err));
},
Expand Down
32 changes: 15 additions & 17 deletions src/routes/projects/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const should = chai.should();
const expect = chai.expect;

describe('Project create', () => {
before((done) => {
before(function beforeHook(done) {
this.timeout(20000);
testUtil.clearDb()
.then(() => testUtil.clearES())
.then(() => models.ProjectType.bulkCreate([
Expand Down Expand Up @@ -76,8 +77,16 @@ describe('Project create', () => {
updatedBy: 4,
},
]))
.then(() => models.ProjectTemplate.bulkCreate([
{
.then(() => {
const exceededProducts = [];
for (let i = 1; i <= _.parseInt(config.get('maxPhaseProductCount')) + 1; i += 1) {
exceededProducts.push({
id: i,
name: `product ${i}`,
productKey: `visual_design_prod${i}`,
});
}
return models.ProjectTemplate.bulkCreate([{
id: 1,
name: 'template 1',
key: 'key 1',
Expand All @@ -91,18 +100,7 @@ describe('Project create', () => {
phase1: {
name: 'phase 1',
duration: 5,
products: [
{
id: 21,
name: 'product 1',
productKey: 'visual_design_prod1',
},
{
id: 22,
name: 'product 2',
productKey: 'visual_design_prod2',
},
],
products: exceededProducts,
},
},
createdBy: 1,
Expand Down Expand Up @@ -206,8 +204,8 @@ describe('Project create', () => {
},
createdBy: 1,
updatedBy: 2,
},
]))
}]);
})
.then(() => models.BuildingBlock.bulkCreate([
{
id: 1,
Expand Down