Skip to content

Commit

Permalink
Remove .custom
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbugli committed Aug 12, 2021
1 parent 2c01fc6 commit 2f6c0d8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CurrentUserPayload_Tests: XCTestCase {
func test_currentUserJSON_customRoleIsDecodedCorrectly() throws {
let json = XCTestCase.mockData(fromFile: "CurrentUserCustomRole")
let payload = try JSONDecoder.default.decode(CurrentUserPayload.self, from: json)
XCTAssertEqual(payload.role, .custom("banana-master"))
XCTAssertEqual(payload.role, UserRole("banana-master"))
}

func test_currentUserJSON_isDecodedCorrectly() throws {
Expand Down
4 changes: 2 additions & 2 deletions Sources/StreamChat/Database/DTOs/CurrentUserDTO_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CurrentUserModelDTO_Tests: XCTestCase {
}

func test_currentUserPayload_customRolesEncoding() throws {
let payload: CurrentUserPayload = .dummy(userPayload: .dummy(userId: .unique, role: .custom("banana-master")))
let payload: CurrentUserPayload = .dummy(userPayload: .dummy(userId: .unique, role: UserRole("banana-master")))

// Asynchronously save the payload to the db
try database.writeSynchronously { session in
Expand All @@ -33,7 +33,7 @@ class CurrentUserModelDTO_Tests: XCTestCase {
database.viewContext.currentUser?.asModel()
)

XCTAssertEqual(.custom("banana-master"), loadedCurrentUser.userRole)
XCTAssertEqual(UserRole("banana-master"), loadedCurrentUser.userRole)
}

func test_currentUserPayload_isStoredAndLoadedFromDB() throws {
Expand Down
4 changes: 0 additions & 4 deletions Sources/StreamChat/Models/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public struct UserRole: RawRepresentable, Codable, Hashable, ExpressibleByString
public init(stringLiteral value: String) {
self.init(rawValue: value)
}

static func custom(_ rawValue: String) -> UserRole {
.init(rawValue: rawValue)
}
}

public extension UserRole {
Expand Down

0 comments on commit 2f6c0d8

Please sign in to comment.