Skip to content

Commit

Permalink
Remove unused queryItem
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdmontgomery committed Dec 10, 2024
1 parent 5cd6c41 commit 2eb1a9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Sources/Gravatar/Network/Services/ProfileService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ public struct ProfileService: ProfileFetching, Sendable {
for avatar: AvatarIdentifier,
token: String
) async throws -> Avatar {
guard let url = avatarsBaseURLComponents
.settingQueryItems([.init(name: "rating", value: rating.rawValue)]).url?
.appendingPathComponent(avatar.id)
guard let url = avatarsBaseURLComponents.url?.appendingPathComponent(avatar.id)
else {
throw APIError.requestError(reason: .urlInitializationFailed)
}
Expand Down
9 changes: 4 additions & 5 deletions Tests/GravatarUITests/AvatarPickerViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ final class URLSessionAvatarPickerMock: URLSessionProtocol {
case avatars
}

enum QueryType: String {
case rating
}

init(returnErrorCode: Int? = nil) {
self.returnErrorCode = returnErrorCode
}
Expand Down Expand Up @@ -313,7 +309,10 @@ final class URLSessionAvatarPickerMock: URLSessionProtocol {
private func isSetAvatarRatingRequest(_ request: URLRequest) -> Bool {
guard request.httpMethod == "PATCH",
request.url?.absoluteString.contains(RequestType.avatars.rawValue) == true,
request.url?.query?.contains(QueryType.rating.rawValue) == true
let bodyData = request.httpBody,
let updateAvatarRequestBody = try? JSONDecoder().decode(UpdateAvatarRequest.self, from: bodyData),
updateAvatarRequestBody.rating != nil

else {
return false
}
Expand Down

0 comments on commit 2eb1a9b

Please sign in to comment.