Skip to content

Commit

Permalink
ID-1353 Use Appropriate Response Codes in User Favorite Resources (#1517
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tlangs authored Aug 14, 2024
1 parent e2cea3f commit c4d92c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/resources/swagger/api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3308,7 +3308,7 @@ paths:
schema:
type: string
responses:
202:
204:
description: Favorite resource added
content: { }
404:
Expand Down Expand Up @@ -3336,7 +3336,7 @@ paths:
schema:
type: string
responses:
202:
204:
description: Favorite resource removed
content: { }
/api/users/v2/{sam_user_id}:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ trait UserRoutesV2 extends SamUserDirectives with SamRequestContextDirectives wi
requireAnyAction(resource, samUser.id, samRequestContext) {
complete {
resourceService.addUserFavoriteResource(samUser.id, resource, samRequestContext).map {
case true => StatusCodes.Accepted
case true => StatusCodes.NoContent
case false => StatusCodes.NotFound
}
}
Expand All @@ -274,7 +274,7 @@ trait UserRoutesV2 extends SamUserDirectives with SamRequestContextDirectives wi
private def removeFavoriteResource(samUser: SamUser, resource: FullyQualifiedResourceId, samRequestContext: SamRequestContext): Route =
deleteWithTelemetry(samRequestContext) {
complete {
resourceService.removeUserFavoriteResource(samUser.id, resource, samRequestContext).map(_ => StatusCodes.Accepted)
resourceService.removeUserFavoriteResource(samUser.id, resource, samRequestContext).map(_ => StatusCodes.NoContent)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class UserRoutesV2Spec extends AnyFlatSpec with Matchers with TimeMatchers with

// Act and Assert
Put(s"/api/users/v2/self/favoriteResources/$resourceType/$resourceId") ~> samRoutes.route ~> check {
status shouldEqual StatusCodes.Accepted
status shouldEqual StatusCodes.NoContent
}
}

Expand Down Expand Up @@ -585,7 +585,7 @@ class UserRoutesV2Spec extends AnyFlatSpec with Matchers with TimeMatchers with

// Act and Assert
Delete(s"/api/users/v2/self/favoriteResources/$resourceType/$resourceId") ~> samRoutes.route ~> check {
status shouldEqual StatusCodes.Accepted
status shouldEqual StatusCodes.NoContent
}
}

Expand All @@ -609,7 +609,7 @@ class UserRoutesV2Spec extends AnyFlatSpec with Matchers with TimeMatchers with

// Act and Assert
Delete(s"/api/users/v2/self/favoriteResources/$resourceType/$resourceId") ~> samRoutes.route ~> check {
status shouldEqual StatusCodes.Accepted
status shouldEqual StatusCodes.NoContent
}
}
}

0 comments on commit c4d92c7

Please sign in to comment.