       try json.set("position", position)
       try json.set("email", email)
       try json.set("phone", phone)
+      try json.set("photo", photo)
     }
     return json
   }

  func sendGetRequest(for id: Identifier) throws -> Response {
    return try drop.clientAuthorizedTestResponse(to: .get, at: "/user/\(id.int!)")
  }
}

    
    XCTAssertEqual(updatedAtMonth, currentMonth)
  }
  
  func testThatUpdateMethodUpdatesUserCredentials() throws {
    let user = try storeUser()
    var updatedUserJSON = try generatedUserJSON()
    try updatedUserJSON.set("lastname", updatedLastName)

    try sendPatchRequest(for: user.id!, with: updatedUserJSON)
    
    let updatedUser = try User.find(user.id!)
    
    XCTAssertEqual(updatedUser!.lastname, updatedLastName)
  }
  
  func testThatUpdateMethodReturnsUpdatedUser() throws {
    let user = try storeUser()
    let newName = String.randomValue
    let newLastName = String.randomValue
    let newCompany = String.randomValue
    let newPosition = String.randomValue
    let newEmail = String.randomEmail
    let newPhoto = String.randomURL
    
    var json = JSON()
    try json.set("name", newName)
    try json.set("lastname", newLastName)
    try json.set("company", newCompany)
    try json.set("position", newPosition)
    try json.set("email", newEmail)
    try json.set("photo", newPhoto)
    
    let response = try drop.clientAuthorizedTestResponse(to: .patch, at: "/user/\((user.id?.int)!)", body: json)
    
    try response.assertJSON("name", equals: newName)
    try response.assertJSON("lastname", equals: newLastName)
    try response.assertJSON("company", equals: newCompany)
    try response.assertJSON("position", equals: newPosition)
    try response.assertJSON("email", equals: newEmail)
    try response.assertJSON("photo", equals: newPhoto)
  }
}

extension UserControllerTests {
