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

Use DELETE method for removing UserProfilePicture instead of PATСH #446

Conversation

Cr1stal423
Copy link
Contributor

@Cr1stal423 Cr1stal423 commented Jan 14, 2025

😎 GreenCity User 😎

Issue Link:
8019
Changes:

Replace PATH with DELETE mapping
Fix the related test

Previous Condition:

image

Current Condition:

image

Summary by CodeRabbit

  • New Features

    • Updated user profile picture deletion endpoint to use the correct HTTP DELETE method
  • Bug Fixes

    • Corrected HTTP method for profile picture deletion to align with RESTful API best practices

Copy link

coderabbitai bot commented Jan 14, 2025

Walkthrough

The pull request modifies the UserController in the GreenCity project, changing the HTTP method for deleting a user's profile picture from @PatchMapping to @DeleteMapping. This semantic adjustment aligns the HTTP verb more accurately with the action of resource deletion. The change is consistently applied across both the controller and its corresponding test class, ensuring that the endpoint now explicitly uses the DELETE method for removing a profile picture.

Changes

File Change Summary
core/src/main/java/greencity/controller/UserController.java Replaced @PatchMapping with @DeleteMapping for profile picture deletion endpoint
core/src/test/java/greencity/controller/UserControllerTest.java Updated test to use delete() method instead of patch() for the profile picture deletion test

Possibly related PRs

Suggested Reviewers

  • holotsvan
  • Warded120
  • ChernenkoVitaliy

Poem

🖼️ Farewell, profile pic so bright,
DELETE now replaces patch's might,
REST API dancing with grace,
One verb change, a semantic embrace!
HTTP methods find their true home 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
core/src/main/java/greencity/controller/UserController.java (1)

344-347: Good change to use DELETE for profile picture removal!

The change from PATCH to DELETE better aligns with REST principles since we're removing a resource. However, consider making the endpoint path more RESTful.

Consider renaming the endpoint to follow REST conventions:

-@DeleteMapping(path = "/deleteProfilePicture")
+@DeleteMapping(path = "/profile-picture")

This makes the endpoint more resource-focused rather than action-focused, which is a REST best practice.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3b5ca8 and ab9891d.

📒 Files selected for processing (2)
  • core/src/main/java/greencity/controller/UserController.java (2 hunks)
  • core/src/test/java/greencity/controller/UserControllerTest.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
core/src/test/java/greencity/controller/UserControllerTest.java (1)

Line range hint 327-332: Test correctly updated to match the new DELETE endpoint!

The test has been properly updated to use the DELETE method and verifies both the service call and response status.

@Cr1stal423 Cr1stal423 changed the title Use DELETE method for removing UserProfilePicture instead of PATH Use DELETE method for removing UserProfilePicture instead of PATСH Jan 14, 2025
@Cr1stal423 Cr1stal423 merged commit 3255a1b into dev Jan 14, 2025
4 checks passed
@Cr1stal423 Cr1stal423 deleted the bugfix/8019/specify-DELETE-method-to-delete-User-Profile-Picture-instead-of-PATH branch January 14, 2025 16:06
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.

[API User-controller] The PATCH method is specified instead DELETE method to delete User Profile Picture
4 participants