forked from Ruderverein-Donau-Linz/rowt
parent
da6a16cd66
commit
f2baca668c
@ -30,7 +30,6 @@ async fn create(
|
|||||||
let data = data.into_inner();
|
let data = data.into_inner();
|
||||||
|
|
||||||
let trip_details_id = TripDetails::create(db, data.tripdetails).await;
|
let trip_details_id = TripDetails::create(db, data.tripdetails).await;
|
||||||
|
|
||||||
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc. we
|
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc. we
|
||||||
//just created
|
//just created
|
||||||
//the object
|
//the object
|
||||||
@ -235,4 +234,41 @@ mod test {
|
|||||||
|
|
||||||
assert_eq!(flash_cookie.value(), "5:errorPlanned event id not found");
|
assert_eq!(flash_cookie.value(), "5:errorPlanned event id not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[sqlx::test]
|
||||||
|
fn test_create() {
|
||||||
|
let db = testdb!();
|
||||||
|
|
||||||
|
let rocket = rocket::build().manage(db.clone());
|
||||||
|
let rocket = crate::tera::config(rocket);
|
||||||
|
|
||||||
|
let client = Client::tracked(rocket).await.unwrap();
|
||||||
|
let login = client
|
||||||
|
.post("/auth")
|
||||||
|
.header(ContentType::Form) // Set the content type to form
|
||||||
|
.body("name=admin&password=admin"); // Add the form data to the request body;
|
||||||
|
login.dispatch().await;
|
||||||
|
|
||||||
|
let req = client
|
||||||
|
.post("/admin/planned-event")
|
||||||
|
.header(ContentType::Form) // Set the content type to form
|
||||||
|
.body("name=my-cool-new-event&planned_amount_cox=42&tripdetails.planned_starting_time=10:01&tripdetails.max_people=3&tripdetails.day=2345-12-20"); // Add the form data to the request body;
|
||||||
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
|
assert_eq!(response.headers().get("Location").next(), Some("/"));
|
||||||
|
|
||||||
|
let flash_cookie = response
|
||||||
|
.cookies()
|
||||||
|
.get("_flash")
|
||||||
|
.expect("Expected flash cookie");
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
flash_cookie.value(),
|
||||||
|
"7:successSuccessfully planned the event"
|
||||||
|
);
|
||||||
|
|
||||||
|
let event = PlannedEvent::find_by_id(&db, 2).await.unwrap();
|
||||||
|
assert_eq!(event.name, "my-cool-new-event");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user