fix-kiosk-error #885

Merged
philipp merged 6 commits from fix-kiosk-error into staging 2025-03-26 20:58:11 +01:00
Showing only changes of commit 18d9f51354 - Show all commits

View File

@ -47,12 +47,13 @@ async fn index(db: &State<SqlitePool>, user: DonauLinzUser, year: Option<i32>) -
async fn index_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie, year: Option<i32>) -> Template { async fn index_kiosk(db: &State<SqlitePool>, _kiosk: KioskCookie, year: Option<i32>) -> Template {
let stat = Stat::people(db, year).await; let stat = Stat::people(db, year).await;
let club_km = Stat::sum_people(db, year).await; let club_km = Stat::sum_people(db, year).await;
let club_trips = Stat::trips_people(db, year).await;
let guest_km = Stat::guest(db, year).await; let guest_km = Stat::guest(db, year).await;
let kiosk = true; let kiosk = true;
Template::render( Template::render(
"stat.people", "stat.people",
context!(stat, kiosk, show_kiosk_header: true, guest_km, club_km), context!(stat, kiosk, show_kiosk_header: true, guest_km, club_km, club_trips),
) )
} }
@ -61,4 +62,30 @@ pub fn routes() -> Vec<Route> {
} }
#[cfg(test)] #[cfg(test)]
mod test {} mod test {
use rocket::{http::Status, local::asynchronous::Client};
use sqlx::SqlitePool;
use crate::testdb;
#[sqlx::test]
fn test_kiosk_stat() {
let db = testdb!();
let rocket = rocket::build().manage(db.clone());
let rocket = crate::tera::config(rocket);
let client = Client::tracked(rocket).await.unwrap();
// "Log in"
let req = client.get("/log/kiosk/ekrv2019/Linz");
let _ = req.dispatch().await;
// `/stat` should be viewable
let req = client.get("/stat");
let response = req.dispatch().await;
assert_eq!(response.status(), Status::Ok);
let text = response.into_string().await.unwrap();
assert!(text.contains("Statistik"));
}
}