httpd: Add author information to assignees
This commit is contained in:
parent
a48081f271
commit
501b6ba9eb
|
|
@ -104,7 +104,9 @@ pub(crate) fn issue(id: IssueId, issue: Issue, aliases: &impl AliasStore) -> Val
|
|||
"author": author(&issue.author(), aliases.alias(issue.author().id())),
|
||||
"title": issue.title(),
|
||||
"state": issue.state(),
|
||||
"assignees": issue.assignees().collect::<Vec<_>>(),
|
||||
"assignees": issue.assignees().map(|assignee|
|
||||
author(&Author::from(*assignee.as_key()), aliases.alias(assignee))
|
||||
).collect::<Vec<_>>(),
|
||||
"discussion": issue.comments().map(|(id, c)| issue_comment(id, c, aliases)).collect::<Vec<_>>(),
|
||||
"labels": issue.labels().collect::<Vec<_>>(),
|
||||
})
|
||||
|
|
@ -125,7 +127,9 @@ pub(crate) fn patch(
|
|||
"target": patch.target(),
|
||||
"labels": patch.labels().collect::<Vec<_>>(),
|
||||
"merges": patch.merges().map(|(nid, m)| merge(nid, m, aliases)).collect::<Vec<_>>(),
|
||||
"assignees": patch.assignees().collect::<Vec<_>>(),
|
||||
"assignees": patch.assignees().map(|assignee|
|
||||
author(&Author::from(*assignee), aliases.alias(&assignee))
|
||||
).collect::<Vec<_>>(),
|
||||
"revisions": patch.revisions().map(|(id, rev)| {
|
||||
json!({
|
||||
"id": id,
|
||||
|
|
|
|||
|
|
@ -2310,6 +2310,78 @@ mod routes {
|
|||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_projects_issues_assign() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = contributor(tmp.path());
|
||||
let app = super::router(ctx.to_owned());
|
||||
|
||||
create_session(ctx).await;
|
||||
|
||||
let body = serde_json::to_vec(&json!({
|
||||
"type": "assign",
|
||||
"assignees": [CONTRIBUTOR_DID],
|
||||
}))
|
||||
.unwrap();
|
||||
|
||||
let response = patch(
|
||||
&app,
|
||||
format!("/projects/{CONTRIBUTOR_RID}/issues/{ISSUE_DISCUSSION_ID}"),
|
||||
Some(Body::from(body)),
|
||||
Some(SESSION_ID.to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
|
||||
let response = get(
|
||||
&app,
|
||||
format!("/projects/{CONTRIBUTOR_RID}/issues/{ISSUE_DISCUSSION_ID}"),
|
||||
)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
response.json().await,
|
||||
json!({
|
||||
"id": ISSUE_DISCUSSION_ID,
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"title": "Issue #1",
|
||||
"state": {
|
||||
"status": "open",
|
||||
},
|
||||
"assignees": [
|
||||
{ "id": CONTRIBUTOR_DID }
|
||||
],
|
||||
"discussion": [
|
||||
{
|
||||
"id": ISSUE_DISCUSSION_ID,
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"timestamp": TIMESTAMP,
|
||||
"embeds": [],
|
||||
},
|
||||
],
|
||||
"embeds": [],
|
||||
"reactions": [],
|
||||
"timestamp": TIMESTAMP,
|
||||
"replyTo": null,
|
||||
"resolved": false,
|
||||
},
|
||||
],
|
||||
"labels": [],
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_projects_issues_reply() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
|
@ -2661,7 +2733,9 @@ mod routes {
|
|||
"target": "delegates",
|
||||
"labels": [],
|
||||
"merges": [],
|
||||
"assignees": [CONTRIBUTOR_DID],
|
||||
"assignees": [
|
||||
{ "id": CONTRIBUTOR_DID }
|
||||
],
|
||||
"revisions": [
|
||||
{
|
||||
"id": CONTRIBUTOR_PATCH_ID,
|
||||
|
|
|
|||
Loading…
Reference in New Issue