fix: set route's method to GET
This commit is contained in:
parent
8045eb979e
commit
e1c27ca308
4 changed files with 23 additions and 33 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::helpers::spawn_app;
|
||||
use reqwest::Url;
|
||||
use wiremock::{ResponseTemplate, Mock};
|
||||
use wiremock::matchers::{path, method};
|
||||
use wiremock::matchers::{method, path};
|
||||
use wiremock::{Mock, ResponseTemplate};
|
||||
|
||||
#[tokio::test]
|
||||
async fn the_link_returned_by_subscribe_returns_a_200_if_called() {
|
||||
|
|
@ -17,28 +17,24 @@ async fn the_link_returned_by_subscribe_returns_a_200_if_called() {
|
|||
|
||||
app.post_subscriptions(body.into()).await;
|
||||
let email_request = &app.email_server.received_requests().await.unwrap()[0];
|
||||
let body: serde_json::Value = serde_json::from_slice(&email_request.body)
|
||||
.unwrap();
|
||||
let body: serde_json::Value = serde_json::from_slice(&email_request.body).unwrap();
|
||||
// Extract the link from one of the request fields.
|
||||
let get_link = |s: &str| {
|
||||
let links: Vec<_> = linkify::LinkFinder::new()
|
||||
.links(s)
|
||||
.filter(|l| *l.kind() == linkify::LinkKind::Url)
|
||||
.filter(|l| *l.kind() == linkify::LinkKind::Url)
|
||||
.collect();
|
||||
assert_eq!(links.len(), 1);
|
||||
links[0].as_str().to_owned()
|
||||
};
|
||||
let raw_confirmation_link = &get_link(body["HtmlBody"].as_str().unwrap());
|
||||
let mut confirmation_link = Url::parse(raw_confirmation_link).unwrap();
|
||||
|
||||
assert_eq!(confirmation_link.host_str().unwrap(), "127.0.0.1");
|
||||
confirmation_link.set_port(Some(app.port)).unwrap();
|
||||
|
||||
println!("\n################################\n{}\n##########################################", confirmation_link);
|
||||
|
||||
// Act
|
||||
let response = reqwest::get(confirmation_link)
|
||||
.await
|
||||
.unwrap();
|
||||
let response = reqwest::get(confirmation_link).await.unwrap();
|
||||
|
||||
// Assert
|
||||
assert_eq!(response.status().as_u16(), 200);
|
||||
|
|
@ -57,4 +53,3 @@ async fn confirmations_without_token_are_rejected_with_a_400() {
|
|||
// Assert
|
||||
assert_eq!(response.status().as_u16(), 400);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue