parent
3730940aed
commit
96af3c3b17
@ -47,7 +47,9 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
|
|||||||
|
|
||||||
#[get("/join/<trip_details_id>")]
|
#[get("/join/<trip_details_id>")]
|
||||||
async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash<Redirect> {
|
async fn join(db: &State<SqlitePool>, trip_details_id: i64, user: User) -> Flash<Redirect> {
|
||||||
let Some(trip_details) = TripDetails::find_by_id(db, trip_details_id).await else { return Flash::error(Redirect::to("/"), "Trip_details do not exist.") };
|
let Some(trip_details) = TripDetails::find_by_id(db, trip_details_id).await else {
|
||||||
|
return Flash::error(Redirect::to("/"), "Trip_details do not exist.");
|
||||||
|
};
|
||||||
|
|
||||||
match UserTrip::create(db, &user, &trip_details).await {
|
match UserTrip::create(db, &user, &trip_details).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -243,4 +245,22 @@ mod test {
|
|||||||
|
|
||||||
assert_eq!(flash_cookie.value(), "5:errorTrip_details do not exist.");
|
assert_eq!(flash_cookie.value(), "5:errorTrip_details do not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_public() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
|
||||||
|
let req = client.get("/public/main.css");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
|
||||||
|
let req = client.get("/public/main.js");
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
assert_eq!(response.status(), Status::Ok);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user