Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add findAll(GET) method in the campaign-application.service(second try) #652

Merged
merged 14 commits into from
Jul 1, 2024

Conversation

Martbul
Copy link
Contributor

@Martbul Martbul commented Jun 27, 2024

Closes #{issue number}

Motivation and context

Testing

Steps to test

New endpoints

Environment

New environment variables:

  • NEW_ENV_VAR: env var details

New or updated dependencies:

Dependency name Previous version Updated version Details
dependency/name v1.0.0 v2.0.0

if any of the 3 agreements for creating campaign are not checked -> throw a HttpException with status 405
http error code is now 400 in validation for all 3 agreements  in create method
changed the error from HttpException to BadRequestException for the agreements validation in create method in campaign-application.service.ts
created findAll functionality in campaign-application.service and add testing for the method
new the mocked campaign-applications in the tests have the right schema(schema of the campaign-application)
Copy link

github-actions bot commented Jun 27, 2024

✅ Tests will run for this PR. Once they succeed it can be merged.

// But actually provide the service that implements the interface
useClass: SendGridNotificationsProvider,
},
CampaignService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all these providers? CampaignService? Vault Service.... and all the rest?
It looks like CampaignApplicationService is the only requirement for this PR's scope

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that all of these would need to be instantiated with all of their dependencies for each test!!!

Instead use mocking (see other tests or look for autoSpy usage)

Copy link
Contributor

@gparlakov gparlakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a bit more ❤️

// But actually provide the service that implements the interface
useClass: SendGridNotificationsProvider,
},
CampaignService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that all of these would need to be instantiated with all of their dependencies for each test!!!

Instead use mocking (see other tests or look for autoSpy usage)

@@ -20,7 +22,7 @@ export class CampaignApplicationService {
}

findAll() {
return `This action returns all campaignApplication`
return this.prisma.campaignApplication.findMany()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The controller would need to be updated to check for authenticated user and allow getting only for admin/operator roles.

remove unused providers in campaign-application.spec.ts
add validation if user is admin in findAll method in campaign-application.controller.ts
add tests for findAll method
@Martbul Martbul requested a review from gparlakov June 28, 2024 17:23
Copy link
Contributor

@gparlakov gparlakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I have missed it.

@Martbul Martbul requested a review from gparlakov June 29, 2024 12:13
@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Jun 30, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Jun 30, 2024
@Martbul
Copy link
Contributor Author

Martbul commented Jun 30, 2024

Трябва ли да правя някакви промени?

@@ -19,7 +19,10 @@ export class CampaignApplicationController {
}

@Get('list')
findAll() {
findAll(@AuthenticatedUser() user: KeycloakTokenParsed) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For further information you could also use the @Roles decorator to guard specific endpoint. You can see its usage from other modules. Specifically for administrators you should look for ViewSupporters.role

@sashko9807 sashko9807 merged commit fec31a0 into podkrepi-bg:master Jul 1, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants