Forum: founders are the first fifteen; the admin can take or give the badge
The site has few members yet, some of them test accounts: the badge goes to the first fifteen, and the admin can take it from a test account on its profile (the place goes to the next newcomer) or give it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1316,16 +1316,18 @@ async fn a_question_about_ones_chart(pool: PgPool) {
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn the_first_hundred_are_founders(pool: PgPool) {
|
||||
async fn the_first_fifteen_are_founders(pool: PgPool) {
|
||||
let app = TestApp::new(pool);
|
||||
let anna = app.member("anna@example.com", "Csendesvíz", &["user"]).await;
|
||||
// Ninety-nine more founders already (made up), then Bea comes too late.
|
||||
let admin = app.member("admin@example.com", "Gondnok", &["admin"]).await;
|
||||
// Thirteen more founders already (made up): fifteen in all, then Bea comes too late.
|
||||
sqlx::query(
|
||||
"WITH u AS (INSERT INTO users (id, email, display_name) \
|
||||
SELECT gen_random_uuid(), 'f' || n || '@example.invalid', 'F' FROM generate_series(1, 99) n \
|
||||
SELECT gen_random_uuid(), 'f' || n || '@example.invalid', 'F' FROM generate_series(1, 13) n \
|
||||
RETURNING id, email) \
|
||||
INSERT INTO forum.members (user_id, nickname, nickname_key, avatar, founder) \
|
||||
SELECT id, 'Alapito ' || email, 'alapito ' || email, 'hold-ejkek', true FROM u",
|
||||
SELECT id, 'Alapito' || split_part(email, '@', 1), \
|
||||
translate('alapito' || split_part(email, '@', 1), 'i10', 'llo'), 'hold-ejkek', true FROM u",
|
||||
)
|
||||
.execute(&app.pool)
|
||||
.await
|
||||
@@ -1336,4 +1338,15 @@ async fn the_first_hundred_are_founders(pool: PgPool) {
|
||||
let shown = app.get(&format!("/v1/forum/threads/{thread}"), None).await;
|
||||
assert_eq!(shown["posts"][0]["author"]["founder"], true);
|
||||
assert_eq!(shown["posts"][1]["author"]["founder"], false);
|
||||
|
||||
// The admin takes it from a test account: the next newcomer gets the place.
|
||||
let uri = "/v1/forum/members/Alapitof1/founder";
|
||||
let (status, _) = app.call("PUT", uri, Some(&anna), json!({ "founder": false })).await;
|
||||
assert_eq!(status, StatusCode::FORBIDDEN);
|
||||
let (status, _) = app.call("PUT", uri, Some(&admin), json!({ "founder": false })).await;
|
||||
assert_eq!(status, StatusCode::NO_CONTENT);
|
||||
let cili = app.member("cili@example.com", "Zöldág", &["user"]).await;
|
||||
app.reply(&cili, thread, "Sziasztok!", None).await;
|
||||
let shown = app.get(&format!("/v1/forum/threads/{thread}"), None).await;
|
||||
assert_eq!(shown["posts"][2]["author"]["founder"], true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user