Register form and confirmation messages
This commit is contained in:
@@ -15,10 +15,11 @@ async fn confirmation_links_without_token_are_rejected_with_a_400() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_link_returned_by_subscribe_returns_a_200_if_called() {
|
||||
async fn clicking_on_the_link_shows_a_confiramtion_message() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let body = "name=Alphonse&email=alphonse.paix%40outlook.com";
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("name=Alphonse&email={email}&email_check={email}");
|
||||
|
||||
Mock::given(path("v1/email"))
|
||||
.and(method("POST"))
|
||||
@@ -27,19 +28,27 @@ async fn the_link_returned_by_subscribe_returns_a_200_if_called() {
|
||||
.mount(&app.email_server)
|
||||
.await;
|
||||
|
||||
app.post_subscriptions(body.into()).await;
|
||||
app.post_subscriptions(body).await;
|
||||
|
||||
let email_request = &app.email_server.received_requests().await.unwrap()[0];
|
||||
let confirmation_links = app.get_confirmation_links(email_request);
|
||||
let response = reqwest::get(confirmation_links.html).await.unwrap();
|
||||
assert_eq!(response.status().as_u16(), 200);
|
||||
assert!(
|
||||
response
|
||||
.text()
|
||||
.await
|
||||
.unwrap()
|
||||
.contains("Your account has been confirmed")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn clicking_on_the_confirmation_link_confirms_a_subscriber() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let body = "name=Alphonse&email=alphonse.paix%40outlook.com";
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("name=Alphonse&email={email}&email_check={email}");
|
||||
|
||||
Mock::given(path("v1/email"))
|
||||
.and(method("POST"))
|
||||
@@ -48,7 +57,7 @@ async fn clicking_on_the_confirmation_link_confirms_a_subscriber() {
|
||||
.mount(&app.email_server)
|
||||
.await;
|
||||
|
||||
app.post_subscriptions(body.into()).await;
|
||||
app.post_subscriptions(body).await;
|
||||
|
||||
let email_request = &app.email_server.received_requests().await.unwrap()[0];
|
||||
let confirmation_links = app.get_confirmation_links(email_request);
|
||||
|
||||
Reference in New Issue
Block a user