Skip to content

Commit

Permalink
Version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amthorn committed May 10, 2021
1 parent 18faa0d commit fa782ba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion services/bot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qutex",
"version": "0.2.0",
"version": "0.2.1",
"description": "",
"main": "index.js",
"types": "src/@types/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions services/bot/src/commands/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export abstract class CommandBase {
const registrations = await REGISTRATION_MODEL.find({ destination: initiative.destination }).exec();
// This is a special case for project delete where a registration is not needed.
if (initiative.action.COMMAND_BASE === 'project' && initiative.action.COMMAND_TYPE === CommandType.DELETE) {
const projects = await PROJECT_MODEL.find({ name: initiative.data.name }).exec();
const projects = await PROJECT_MODEL.find({ name: initiative.data.name.toUpperCase() }).exec();
if (projects.length > 0) {
return projects[0];
} else {
return `A project with name "${initiative.data.name}" does not exist.`;
return `A project with name "${initiative.data.name.toUpperCase()}" does not exist.`;
}
} else if (registrations.length > 0) {
const projects = await PROJECT_MODEL.find({ name: registrations[0].projectName }).exec();
Expand Down
2 changes: 1 addition & 1 deletion services/bot/src/commands/projects/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Delete extends CommandBase implements ICommand {
*/
public async relax (initiative: IInitiative): Promise<string> {
// Will always exist. If it doesn't, the authorizer should thrown a project not found error.
await PROJECT_MODEL.deleteOne(initiative.data).exec();
await PROJECT_MODEL.deleteOne({ name: initiative.data.name.toUpperCase() }).exec();
return `Successfully deleted "${initiative.data.name.toUpperCase()}"`;
}
}
7 changes: 7 additions & 0 deletions services/bot/tests/commands/projects/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ describe('Delete project works appropriately', () => {
expect(await new Delete().relax(TEST_INITIATIVE)).toEqual('Successfully deleted "PNAME"');
expect(await PROJECT_MODEL.find({}).exec()).toHaveLength(0);
});
test('project is deleted when the project exists and user does have permissions case insensitive', async () => {
expect(await PROJECT_MODEL.find({}).exec()).toHaveLength(0);
await CREATE_PROJECT();
expect(await PROJECT_MODEL.find({}).exec()).toHaveLength(1);
expect(await new Delete().relax({ ...TEST_INITIATIVE, data: { name: 'pname' } })).toEqual('Successfully deleted "PNAME"');
expect(await PROJECT_MODEL.find({}).exec()).toHaveLength(0);
});
test('project is not deleted when project exists and user does not have access', async () => {
expect(await PROJECT_MODEL.find({}).exec()).toHaveLength(0);
await CREATE_PROJECT();
Expand Down
5 changes: 3 additions & 2 deletions settings.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TODO: Better way of deploying this instead of modifying this file on production server with vim.
WEBEX_LOG_LEVEL=DEBUG
VERSION=0.2.0
VERSION=0.2.1
AUTHOR_NAME=Ava Thorn
AUTHOR_EMAIL=[email protected]
RELEASE_DATE=April 28, 2021
RELEASE_DATE=May 10, 2021
SUPER_ADMINS=["Y2lzY29zcGFyazovL3VzL1BFT1BMRS9kODRkZjI1MS1iYmY3LTRlZTEtOTM1OS00Y2I0MGIyOTBhN2I"]

0 comments on commit fa782ba

Please sign in to comment.