Unsubscribe option available on website
This commit is contained in:
@@ -22,16 +22,12 @@ async fn subscriber_can_unsubscribe() {
|
||||
.expect("Failed to fetch saved token");
|
||||
|
||||
let response = app
|
||||
.get_unsubscribe(
|
||||
record
|
||||
.unsubscribe_token
|
||||
.expect("Confirmed subscriber should have a valid unsubscribe token"),
|
||||
)
|
||||
.get_unsubscribe_confirm(&record.unsubscribe_token.unwrap())
|
||||
.await;
|
||||
|
||||
assert_eq!(response.status().as_u16(), 200);
|
||||
let html_fragment = response.text().await.unwrap();
|
||||
assert!(html_fragment.contains("Good bye, old friend"));
|
||||
assert!(html_fragment.contains("Good bye, friend"));
|
||||
|
||||
let record = sqlx::query!("SELECT email FROM subscriptions")
|
||||
.fetch_optional(&app.connection_pool)
|
||||
@@ -120,9 +116,11 @@ async fn an_invalid_unsubscribe_token_is_rejected() {
|
||||
let app = TestApp::spawn().await;
|
||||
app.create_confirmed_subscriber().await;
|
||||
|
||||
let response = reqwest::get(format!("{}/unsubscribe?token=invalid", app.address))
|
||||
.await
|
||||
.unwrap();
|
||||
let response = app.get_unsubscribe_confirm("invalid-token").await;
|
||||
|
||||
// let response = reqwest::get(format!("{}/unsubscribe?token=invalid", app.address))
|
||||
// .await
|
||||
// .unwrap();
|
||||
|
||||
assert_eq!(response.status().as_u16(), 404);
|
||||
}
|
||||
@@ -139,16 +137,12 @@ async fn subscription_works_after_unsubscribe() {
|
||||
let email = record.email;
|
||||
|
||||
let response = app
|
||||
.get_unsubscribe(
|
||||
record
|
||||
.unsubscribe_token
|
||||
.expect("Confirmed subscriber should have a valid unsubscribe token"),
|
||||
)
|
||||
.get_unsubscribe_confirm(&record.unsubscribe_token.unwrap())
|
||||
.await;
|
||||
|
||||
assert_eq!(response.status().as_u16(), 200);
|
||||
let html_fragment = response.text().await.unwrap();
|
||||
assert!(html_fragment.contains("Good bye, old friend"));
|
||||
assert!(html_fragment.contains("Good bye, friend"));
|
||||
|
||||
let record = sqlx::query!("SELECT email, unsubscribe_token FROM subscriptions")
|
||||
.fetch_optional(&app.connection_pool)
|
||||
|
||||
Reference in New Issue
Block a user