Remove name from subscriptions table
This commit is contained in:
@@ -34,20 +34,19 @@ async fn subscribe_persists_the_new_subscriber() {
|
||||
.await;
|
||||
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("name=Alphonse&email={0}&email_check={0}", email);
|
||||
let body = format!("email={email}");
|
||||
let response = app.post_subscriptions(body).await;
|
||||
|
||||
assert_is_redirect_to(&response, "/register");
|
||||
let page_html = app.get_register_html().await;
|
||||
assert!(page_html.contains("A confirmation email has been sent"));
|
||||
|
||||
let saved = sqlx::query!("SELECT email, name, status FROM subscriptions")
|
||||
let saved = sqlx::query!("SELECT email, status FROM subscriptions")
|
||||
.fetch_one(&app.connection_pool)
|
||||
.await
|
||||
.expect("Failed to fetch saved subscription");
|
||||
|
||||
assert_eq!(saved.email, "alphonse.paix@outlook.com");
|
||||
assert_eq!(saved.name, "Alphonse");
|
||||
assert_eq!(saved.status, "pending_confirmation");
|
||||
}
|
||||
|
||||
@@ -55,21 +54,13 @@ async fn subscribe_persists_the_new_subscriber() {
|
||||
async fn subscribe_returns_a_422_when_data_is_missing() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let test_cases = [
|
||||
("name=Alphonse", "missing the email"),
|
||||
("email=alphonse.paix%40outlook.com", "missing the name"),
|
||||
("", "missing both name and email"),
|
||||
];
|
||||
for (invalid_body, error_message) in test_cases {
|
||||
let response = app.post_subscriptions(invalid_body.into()).await;
|
||||
let response = app.post_subscriptions(String::new()).await;
|
||||
|
||||
assert_eq!(
|
||||
422,
|
||||
response.status().as_u16(),
|
||||
"the API did not fail with 422 Unprocessable Entity when the payload was {}.",
|
||||
error_message
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
422,
|
||||
response.status().as_u16(),
|
||||
"the API did not fail with 422 Unprocessable Entity when the payload was missing the email"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user