diff --git a/src/routes/mod.rs b/src/routes/mod.rs index d0ddba0..1055760 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,7 +1,9 @@ mod health_check; +mod newsletters; mod subscriptions; mod subscriptions_confirm; pub use health_check::*; +pub use newsletters::*; pub use subscriptions::*; pub use subscriptions_confirm::*; diff --git a/src/routes/newsletters.rs b/src/routes/newsletters.rs new file mode 100644 index 0000000..aba10ad --- /dev/null +++ b/src/routes/newsletters.rs @@ -0,0 +1,5 @@ +use actix_web::HttpResponse; + +pub async fn publish_newsletter() -> HttpResponse { + HttpResponse::Ok().finish() +} diff --git a/src/startup.rs b/src/startup.rs index be72d21..60336fd 100644 --- a/src/startup.rs +++ b/src/startup.rs @@ -1,6 +1,6 @@ use crate::configuration::{DatabaseSettings, Settings}; use crate::email_client::EmailClient; -use crate::routes::{confirm, health_check, subscribe}; +use crate::routes::{confirm, health_check, publish_newsletter, subscribe}; use actix_web::dev::Server; use actix_web::web::Data; use actix_web::{web, App, HttpServer}; @@ -79,6 +79,7 @@ fn run( .route("/health_check", web::get().to(health_check)) .route("/subscriptions", web::post().to(subscribe)) .route("/subscriptions/confirm", web::get().to(confirm)) + .route("/newsletters", web::post().to(publish_newsletter)) .app_data(db_pool.clone()) .app_data(email_client.clone()) .app_data(base_url.clone()) diff --git a/tests/api/newsletter.rs b/tests/api/newsletter.rs index 28f9c1b..9ad5fcf 100644 --- a/tests/api/newsletter.rs +++ b/tests/api/newsletter.rs @@ -1,5 +1,5 @@ use crate::helpers::{spawn_app, ConfirmationLinks, TestApp}; -use wiremock::matchers::{method, path}; +use wiremock::matchers::{method, path, any}; use wiremock::{Mock, ResponseTemplate}; async fn create_unconfirmed_subscriber(app: &TestApp) -> ConfirmationLinks { @@ -42,8 +42,7 @@ async fn newsletters_are_not_delivered_to_unconfirmed_subscribers() { let app = spawn_app().await; create_unconfirmed_subscriber(&app).await; - Mock::given(path("/email")) - .and(method("POST")) + Mock::given(any()) .respond_with(ResponseTemplate::new(200)) .expect(0) .mount(&app.email_server)