diff --git a/src/routes/projects/update.spec.js b/src/routes/projects/update.spec.js index f1cb51ef..8f76cc57 100644 --- a/src/routes/projects/update.spec.js +++ b/src/routes/projects/update.spec.js @@ -66,6 +66,7 @@ describe('Project', () => { details: {}, createdBy: 1, updatedBy: 1, + templateId: 1, lastActivityAt: 1, lastActivityUserId: '1', createdAt: '2016-06-30 00:33:07+00', @@ -79,6 +80,7 @@ describe('Project', () => { details: {}, createdBy: 1, updatedBy: 1, + templateId: 1, lastActivityAt: 1, lastActivityUserId: '1', createdAt: '2016-06-30 00:33:07+00', @@ -91,6 +93,7 @@ describe('Project', () => { details: {}, createdBy: 1, updatedBy: 1, + templateId: 1, lastActivityAt: 1, lastActivityUserId: '1', createdAt: '2016-06-30 00:33:07+00', @@ -119,6 +122,12 @@ describe('Project', () => { userId: 40051332, createdBy: 1, updatedBy: 1, + }, { + projectId: project1.id, + role: 'member', + userId: 40051331, + createdBy: 1, + updatedBy: 1, }]); }).then(() => done()); }); @@ -179,6 +188,84 @@ describe('Project', () => { }); }); + it('should not update the templateId for admin', (done) => { + request(server) + .patch(`/v4/projects/${project1.id}`) + .set({ + Authorization: `Bearer ${testUtil.jwts.admin}`, + }) + .send({ + param: { + templateId: 2, + }, + }) + .expect('Content-Type', /json/) + .expect(200) + .end((err, res) => { + if (err) { + done(err); + } else { + const result = res.body.result; + result.success.should.be.true; + result.status.should.equal(200); + result.content.templateId.should.equal(project1.templateId); + done(); + } + }); + }); + + it('should not update the templateId for manager', (done) => { + request(server) + .patch(`/v4/projects/${project1.id}`) + .set({ + Authorization: `Bearer ${testUtil.jwts.manager}`, + }) + .send({ + param: { + templateId: 2, + }, + }) + .expect('Content-Type', /json/) + .expect(200) + .end((err, res) => { + if (err) { + done(err); + } else { + const result = res.body.result; + result.success.should.be.true; + result.status.should.equal(200); + result.content.templateId.should.equal(project1.templateId); + done(); + } + }); + }); + + it('should not update the templateId for user', (done) => { + request(server) + .patch(`/v4/projects/${project1.id}`) + .set({ + Authorization: `Bearer ${testUtil.jwts.member}`, + }) + .send({ + param: { + templateId: 2, + }, + }) + .expect('Content-Type', /json/) + .expect(200) + .end((err, res) => { + if (err) { + done(err); + } else { + const result = res.body.result; + result.success.should.be.true; + result.status.should.equal(200); + result.content.templateId.should.equal(project1.templateId); + done(); + } + }); + }); + it('should return 200 if topcoder manager user will update a project', (done) => { request(server) .patch(`/v4/projects/${project1.id}`)