Added optional user name.
This commit is contained in:
@@ -37,7 +37,10 @@ impl AccountMemberResponse {
|
||||
pub fn from_domain(member: domain::AccountMember, user: domain::User) -> Self {
|
||||
Self {
|
||||
id: member.id,
|
||||
user: UserResponse { id: user.id },
|
||||
user: UserResponse {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +48,7 @@ impl AccountMemberResponse {
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UserResponse {
|
||||
pub id: Uuid,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -60,12 +64,18 @@ mod tests {
|
||||
fn response(id: Uuid, user: domain::User) -> AccountMemberResponse {
|
||||
AccountMemberResponse {
|
||||
id,
|
||||
user: UserResponse { id: user.id },
|
||||
user: UserResponse {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn user() -> domain::User {
|
||||
domain::User { id: Uuid::nil() }
|
||||
domain::User {
|
||||
id: Uuid::nil(),
|
||||
name: Some("Test User".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -75,6 +85,7 @@ mod tests {
|
||||
|
||||
assert_eq!(response["id"], id.to_string());
|
||||
assert_eq!(response["user"]["id"], Uuid::nil().to_string());
|
||||
assert_eq!(response["user"]["name"], "Test User");
|
||||
assert!(response.get("account_id").is_none());
|
||||
}
|
||||
|
||||
@@ -99,5 +110,6 @@ mod tests {
|
||||
let response = response(id, user());
|
||||
assert_eq!(response.id, id);
|
||||
assert_eq!(response.user.id, Uuid::nil());
|
||||
assert_eq!(response.user.name, Some("Test User".to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user