-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2634 from Abobos/feature/update-organisation
feat: Implement rename organization
- Loading branch information
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
apps/api/src/app/organization/e2e/rename-organization.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { OrganizationRepository } from '@novu/dal'; | ||
import { UserSession } from '@novu/testing'; | ||
import { expect } from 'chai'; | ||
|
||
describe('Rename Organization - /organizations (PATCH)', function () { | ||
let session: UserSession; | ||
const organizationRepository = new OrganizationRepository(); | ||
|
||
beforeEach(async () => { | ||
session = new UserSession(); | ||
await session.initialize(); | ||
}); | ||
|
||
it('should rename the organization', async function () { | ||
const payload = { | ||
name: 'Liberty Powers', | ||
}; | ||
|
||
await session.testAgent.patch('/v1/organizations').send(payload); | ||
|
||
const organization = await organizationRepository.findById(session.organization._id); | ||
|
||
expect(organization?.name).to.equal(payload.name); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
apps/api/src/app/organization/usecases/rename-organization/rename-organization-command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { IsDefined, MaxLength } from 'class-validator'; | ||
import { AuthenticatedCommand } from '../../../shared/commands/authenticated.command'; | ||
|
||
export class RenameOrganizationCommand extends AuthenticatedCommand { | ||
@IsDefined() | ||
public readonly id: string; | ||
|
||
@MaxLength(50) | ||
name: string; | ||
} |
18 changes: 18 additions & 0 deletions
18
apps/api/src/app/organization/usecases/rename-organization/rename-organization.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { OrganizationRepository } from '@novu/dal'; | ||
import { RenameOrganizationCommand } from './rename-organization-command'; | ||
|
||
@Injectable() | ||
export class RenameOrganization { | ||
constructor(private organizationRepository: OrganizationRepository) {} | ||
|
||
async execute(command: RenameOrganizationCommand) { | ||
const payload = { | ||
name: command.name, | ||
}; | ||
|
||
await this.organizationRepository.renameOrganization(command.id, payload); | ||
|
||
return payload; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters