add test; fix bug
This commit is contained in:
parent
e3d917ed82
commit
38732df6c8
@ -6,7 +6,7 @@
|
||||
- [] max_people = 0 -> Rot hervorheben, dass Ausfahrt abgesagt wurde?
|
||||
- [] my trips for cox
|
||||
- [] remove key from src/rest/admin/rss.rs (line 8); at least before putting code somewhere public
|
||||
- [] add `trip_type` (id, name, desc, question) with a FK to `trip_details`
|
||||
- [] add `trip_type` (id, name, desc, question, icon) with a FK to `trip_details`
|
||||
- [] add `always_show` to `planned_trips` (e.g. for wanderfahrten)
|
||||
- [] exactly same time -> deny registration
|
||||
- [] `planned_events` -> ICS feed to be [integrated](https://icscalendar.com/shortcode-overview/) in homepage calendar
|
||||
|
@ -5,7 +5,7 @@ use sqlx::SqlitePool;
|
||||
use super::{
|
||||
planned_event::{PlannedEvent, Registration},
|
||||
tripdetails::TripDetails,
|
||||
user::{CoxUser, User},
|
||||
user::CoxUser,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
@ -184,9 +184,13 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM trip WHERE i
|
||||
.unwrap(); //TODO: handle case where cox is not registered
|
||||
}
|
||||
|
||||
pub(crate) async fn delete(&self, db: &SqlitePool, user: &User) -> Result<(), TripDeleteError> {
|
||||
pub(crate) async fn delete(
|
||||
&self,
|
||||
db: &SqlitePool,
|
||||
user: &CoxUser,
|
||||
) -> Result<(), TripDeleteError> {
|
||||
let registered_rower = self.get_all_rower(db).await;
|
||||
if registered_rower.is_empty() {
|
||||
if !registered_rower.is_empty() {
|
||||
return Err(TripDeleteError::SomebodyAlreadyRegistered);
|
||||
}
|
||||
|
||||
@ -357,5 +361,20 @@ mod test {
|
||||
assert!(Trip::find_by_id(&pool, 2).await.is_none());
|
||||
}
|
||||
|
||||
//TODO: create tests for delete() function
|
||||
#[sqlx::test]
|
||||
fn test_succ_delete() {
|
||||
let pool = testdb!();
|
||||
|
||||
let cox: CoxUser = User::find_by_name(&pool, "cox".into())
|
||||
.await
|
||||
.unwrap()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
|
||||
let trip = Trip::find_by_id(&pool, 1).await.unwrap();
|
||||
|
||||
trip.delete(&pool, &cox).await.unwrap();
|
||||
|
||||
assert!(Trip::find_by_id(&pool, 1).await.is_none());
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ pub enum UserTripError {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::testdb;
|
||||
//use crate::testdb;
|
||||
|
||||
//use super::User;
|
||||
//use sqlx::SqlitePool;
|
||||
|
Loading…
Reference in New Issue
Block a user