Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Production release : Logged out project creation flow #72

Merged
merged 6 commits into from
Aug 8, 2017
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
5 changes: 3 additions & 2 deletions src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ module.exports = {
created: {
title: 'Your project has been created, and we\'re ready for your specification',
content: data => `Hello, Coder here! Your project '${data.projectName}' has been created successfully. For your next step, please head over to the <a href="${data.projectUrl}specification/" rel="nofollow">Specification</a> section and answer all of the required questions. If you already have a document with your requirements, just verify it against our checklist and then upload it. Once you're done, hit the "Submit for Review" button on the Specification. Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.`,
disabled: true,
},
submittedForReview: {
title: 'Your project has been submitted for review',
content: data => `Hello, it's Coder again. Thanks for submitting your project <a href="${data.projectUrl}" rel="nofollow">${data.projectName}</a>! I've used my super computational powers to route it to one of our trusty humans. They'll get back to you in 1-2 business days.`,
title: 'Your project is being reviewed. Provide additional info if you have it.',
content: data => `Hello, Coder here! Thanks for submitting your project <a href="${data.projectUrl}" rel="nofollow">${data.projectName}</a>! I've used my super computational powers to route it to one of our trusty humans. They'll get back to you in 1-2 business days. Meanwhile, if have any additional project information or documents to upload, please head over to the <a href="${data.projectUrl}specification/" rel="nofollow">Specification</a> section. Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.`,
},
activated: {
title: 'Work on your project has begun',
Expand Down
17 changes: 10 additions & 7 deletions src/handlers/projectEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ const util = require('./util');
* @return {Array} the array of notifications
*/
function projectDraftCreated(logger, project) {
const notifications = {
discourse: [],
};
const topic = constants.notifications.discourse.project.created;
const topicData = {
projectName: project.name,
projectUrl: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${project.id}/`,
};
// return notificaiton object with discourse data
const notifications = {
discourse: [{
if (topic && !topic.disabled) {
// return notificaiton object with discourse data
notifications.discourse.push({
projectId: project.id,
title: topic.title,
content: topic.content(topicData),
}],
};
});
}
return notifications;
}

Expand Down Expand Up @@ -88,8 +91,8 @@ function* projectUpdated(logger, data) {
topic = constants.notifications.discourse.project.completed;
}

// post to discourse if topic is set
if (topic) {
// post to discourse if topic is set and is not disabled
if (topic && !topic.disabled) {
const topicData = {
projectName: project.name,
projectUrl: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${project.id}/`,
Expand Down
12 changes: 4 additions & 8 deletions src/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,10 @@ describe('app', () => {
});

describe('`project.draft-created` event', () => {
it('should create `Project.Created` notification', (done) => {
it('should not create `Project.Created` notification as it is disabled now', (done) => {
sendTestEvent(sampleEvents.draftCreated, 'project.draft-created');
setTimeout(() => {
const expectedTitle = 'Your project has been created, and we\'re ready for your specification';
const expectedBody = 'Hello, Coder here! Your project \'test\' has been created successfully. For your next step, please head over to the <a href="https://connect.topcoder-dev.com/projects/1/specification/" rel="nofollow">Specification</a> section and answer all of the required questions. If you already have a document with your requirements, just verify it against our checklist and then upload it. Once you\'re done, hit the "Submit for Review" button on the Specification. Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.';
const params = spy.lastCall.args;
assert.equal(params[2], expectedTitle);
assert.equal(params[3], expectedBody);
sinon.assert.notCalled(spy);
done();
}, testTimeout);
});
Expand All @@ -262,8 +258,8 @@ describe('app', () => {
sendTestEvent(sampleEvents.updatedInReview, 'project.updated');
setTimeout(() => {
assertCount += 1;
const expectedTitle = 'Your project has been submitted for review';
const expectedBody = 'Hello, it\'s Coder again. Thanks for submitting your project <a href="https://connect.topcoder-dev.com/projects/1/" rel="nofollow">test</a>! I\'ve used my super computational powers to route it to one of our trusty humans. They\'ll get back to you in 1-2 business days.';
const expectedTitle = 'Your project is being reviewed. Provide additional info if you have it.';
const expectedBody = 'Hello, Coder here! Thanks for submitting your project <a href="https://connect.topcoder-dev.com/projects/1/" rel="nofollow">test</a>! I\'ve used my super computational powers to route it to one of our trusty humans. They\'ll get back to you in 1-2 business days. Meanwhile, if have any additional project information or documents to upload, please head over to the <a href="https://connect.topcoder-dev.com/projects/1/specification/" rel="nofollow">Specification</a> section. Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.';
let params = spy.lastCall.args;
assert.equal(params[2], expectedTitle);
assert.equal(params[3], expectedBody);
Expand Down