Ajoute l'URL du repo sur les projets

Colonne projects.repo_url (migration 0003), exposée par l'API
(repo_url à la création, "" ou null pour l'effacer) et éditable sur la
page clients ; une icône ouvre le repo dans un nouvel onglet. Seules les
URL http(s) sont acceptées.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Romulus21andClaude Opus 5.5 committed 2026-11-13 18:59:20 +01:00
1 parent 9e136bd208
commit 63ddfd39d9
11 files changed
+126 -8

No files matched your search

+52
View File
@@ -707,3 +707,55 @@ async fn move_timer_start() {
let (status, _) = send_form(&app, "/ui/timer/debut", &format!("started_at={future}")).await;
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
}
#[tokio::test]
async fn project_repo_url() {
let app = app().await;
let (_, c) = send(
&app,
"POST",
"/api/clients",
Some(json!({ "name": "Acme" })),
)
.await;
let uri = format!("/api/clients/{}/projects", c["id"]);
let (status, p) = send(
&app,
"POST",
&uri,
Some(json!({ "name": "Site", "repo_url": " https://git.example.com/acme/site " })),
)
.await;
assert_eq!(status, StatusCode::CREATED);
assert_eq!(p["repo_url"], "https://git.example.com/acme/site");
let (status, _) = send(
&app,
"POST",
&uri,
Some(json!({ "name": "Bad", "repo_url": "git@example.com:acme/site.git" })),
)
.await;
assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY);
// Absent: unchanged; "" clears it.
let project = format!("/api/projects/{}", p["id"]);
let (_, p) = send(&app, "PATCH", &project, Some(json!({ "name": "Site web" }))).await;
assert_eq!(p["repo_url"], "https://git.example.com/acme/site");
let (_, html) = get_html(&app, "/clients").await;
assert!(html.contains("href=\"https://git.example.com/acme/site\""));
let (_, p) = send(&app, "PATCH", &project, Some(json!({ "repo_url": "" }))).await;
assert!(p["repo_url"].is_null());
// HTML form: the URL field is saved with the project.
let (status, _) = send_form(
&app,
&project.replace("/api/", "/ui/"),
"name=Site+web&repo_url=https%3A%2F%2Fgit.example.com%2Fx",
)
.await;
assert_eq!(status, StatusCode::SEE_OTHER);
let (_, p) = send(&app, "GET", &format!("{uri}?archived=true"), None).await;
assert_eq!(p[0]["repo_url"], "https://git.example.com/x");
}