mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-24 17:11:49 +00:00
refactor: post details endpoint
This commit is contained in:
parent
44f036a4c4
commit
1a7d95fb3d
2 changed files with 6 additions and 5 deletions
|
|
@ -43,12 +43,12 @@ pub fn rocket() -> Rocket<Build>{
|
||||||
routes::candidate::logout,
|
routes::candidate::logout,
|
||||||
routes::candidate::whoami,
|
routes::candidate::whoami,
|
||||||
routes::candidate::get_details,
|
routes::candidate::get_details,
|
||||||
|
routes::candidate::post_details,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.mount(
|
.mount(
|
||||||
"/candidate/add",
|
"/candidate/add",
|
||||||
routes![
|
routes![
|
||||||
routes::candidate::add_details,
|
|
||||||
routes::candidate::upload_portfolio_letter,
|
routes::candidate::upload_portfolio_letter,
|
||||||
routes::candidate::upload_portfolio_zip,
|
routes::candidate::upload_portfolio_zip,
|
||||||
routes::candidate::upload_cover_letter,
|
routes::candidate::upload_cover_letter,
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,9 @@ pub async fn whoami(session: CandidateAuth) -> Result<String, Custom<String>> {
|
||||||
Ok(candidate.application.to_string())
|
Ok(candidate.application.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: use put instead of post???
|
||||||
#[post("/details", data = "<details>")]
|
#[post("/details", data = "<details>")]
|
||||||
pub async fn add_details(
|
pub async fn post_details(
|
||||||
conn: Connection<'_, Db>,
|
conn: Connection<'_, Db>,
|
||||||
details: Json<ApplicationDetails>,
|
details: Json<ApplicationDetails>,
|
||||||
session: CandidateAuth,
|
session: CandidateAuth,
|
||||||
|
|
@ -397,7 +398,7 @@ mod tests {
|
||||||
let details_orig: ApplicationDetails = serde_json::from_str(CANDIDATE_DETAILS).unwrap();
|
let details_orig: ApplicationDetails = serde_json::from_str(CANDIDATE_DETAILS).unwrap();
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("/candidate/add/details")
|
.post("/candidate/details")
|
||||||
.cookie(cookies.0.clone())
|
.cookie(cookies.0.clone())
|
||||||
.cookie(cookies.1.clone())
|
.cookie(cookies.1.clone())
|
||||||
.body(CANDIDATE_DETAILS.to_string())
|
.body(CANDIDATE_DETAILS.to_string())
|
||||||
|
|
@ -427,7 +428,7 @@ mod tests {
|
||||||
let key = Cookie::new("key", private_key);
|
let key = Cookie::new("key", private_key);
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("/candidate/add/details")
|
.post("/candidate/details")
|
||||||
.cookie(id.clone())
|
.cookie(id.clone())
|
||||||
.cookie(key.clone())
|
.cookie(key.clone())
|
||||||
.body(CANDIDATE_DETAILS.to_string())
|
.body(CANDIDATE_DETAILS.to_string())
|
||||||
|
|
@ -455,7 +456,7 @@ mod tests {
|
||||||
let cookies = admin_login(&client);
|
let cookies = admin_login(&client);
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("/candidate/add/details")
|
.post("/candidate/details")
|
||||||
.cookie(cookies.0.clone())
|
.cookie(cookies.0.clone())
|
||||||
.cookie(cookies.1.clone())
|
.cookie(cookies.1.clone())
|
||||||
.body(CANDIDATE_DETAILS.to_string())
|
.body(CANDIDATE_DETAILS.to_string())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue