forked from Ruderverein-Donau-Linz/rowt
		
	Merge pull request 'fix-kiosk-error' (#885) from fix-kiosk-error into staging
Reviewed-on: Ruderverein-Donau-Linz/rowt#885
This commit is contained in:
		@@ -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 {
 | 
			
		||||
    let stat = Stat::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 kiosk = true;
 | 
			
		||||
 | 
			
		||||
    Template::render(
 | 
			
		||||
        "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)]
 | 
			
		||||
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"));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user