Skip to content
Merged
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
87 changes: 87 additions & 0 deletions src/routes/projects/update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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());
});
Expand Down Expand Up @@ -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}`)
Expand Down