Skip to content

Commit

Permalink
fix(userController): use DELETE method for removing UserProfilePicture (
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr1stal423 authored Jan 14, 2025
1 parent c3b5ca8 commit 3255a1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/greencity/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -340,7 +341,7 @@ public ResponseEntity<HttpStatus> updateUserProfilePicture(
@ApiResponse(responseCode = "400", description = HttpStatuses.BAD_REQUEST),
@ApiResponse(responseCode = "401", description = HttpStatuses.UNAUTHORIZED),
})
@PatchMapping(path = "/deleteProfilePicture")
@DeleteMapping(path = "/deleteProfilePicture")
public ResponseEntity<HttpStatus> deleteUserProfilePicture(Principal principal) {
userService.deleteUserProfilePicture(principal.getName());
return ResponseEntity.ok().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand Down Expand Up @@ -322,7 +324,7 @@ void updateUserProfilePictureTest() throws Exception {
void deleteUserProfilePictureTest() throws Exception {
Principal principal = mock(Principal.class);
when(principal.getName()).thenReturn("[email protected]");
mockMvc.perform(patch(userLink + "/deleteProfilePicture")
mockMvc.perform(delete(userLink + "/deleteProfilePicture")
.principal(principal))
.andExpect(status().isOk());

Expand Down

0 comments on commit 3255a1b

Please sign in to comment.