Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b844644

Browse files
chore: refactored code for formatting CI
1 parent a84d066 commit b844644

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

‎src/routes/admin/newsletters/post.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use sqlx::{PgPool, Postgres, Transaction};
1010
use uuid::Uuid;
1111

1212
#[derive(serde::Deserialize)]
13-
pub struct FormData {
13+
pub struct NewsletterContent {
1414
title: String,
1515
text_content: String,
1616
html_content: String,
@@ -23,12 +23,12 @@ name = "Publish a newsletter issue",
2323
fields(user_id = %*user_id)
2424
)]
2525
pub async fn publish_newsletter(
26-
form: web::Form<FormData>,
26+
form: web::Form<NewsletterContent>,
2727
pool: web::Data<PgPool>,
2828
user_id: ReqData<UserId>,
2929
) -> Result<HttpResponse, actix_web::Error> {
3030
let user_id = user_id.into_inner();
31-
let FormData {
31+
let NewsletterContent {
3232
title,
3333
text_content,
3434
html_content,

‎tests/api/newsletter.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use fake::Fake;
55
use std::time::Duration;
66
use uuid::Uuid;
77
use wiremock::matchers::{any, method, path};
8-
use wiremock::{Mock, MockBuilder,ResponseTemplate};
8+
use wiremock::{Mock, ResponseTemplate};
99

1010
async fn create_unconfirmed_subscriber(app: &TestApp) -> ConfirmationLinks {
1111
let name = Name().fake::<String>();
@@ -46,10 +46,6 @@ async fn create_confirmed_subscriber(app: &TestApp) {
4646
.unwrap();
4747
}
4848

49-
fn when_sending_an_email() -> MockBuilder {
50-
Mock::given(path("/email")).and(method("POST"))
51-
}
52-
5349
#[tokio::test]
5450
async fn you_must_be_logged_in_to_see_the_newsletter_form() {
5551
// Arrange
@@ -70,7 +66,7 @@ async fn you_must_be_logged_in_to_publish_a_newsletter() {
7066
"title": "Newsletter title",
7167
"text_content": "Newsletter content",
7268
"html_content": "<p>Newsletter content</p>",
73-
"idempotency_key": uuid::Uuid::new_v4().to_string()
69+
"idempotency_key": Uuid::new_v4().to_string()
7470
}
7571
);
7672

@@ -97,7 +93,7 @@ async fn newsletters_are_not_delivered_to_unconfirmed_subscribers() {
9793
"title": "Newsletter title",
9894
"text_content": "Newsletter content",
9995
"html_content": "<p>Newsletter content</p>",
100-
"idempotency_key": uuid::Uuid::new_v4().to_string()
96+
"idempotency_key": Uuid::new_v4().to_string()
10197
}
10298
);
10399

@@ -130,7 +126,7 @@ async fn newsletters_are_delivered_to_confirmed_subscribers() {
130126
"title": "Newsletter title",
131127
"text_content": "Newsletter body as plain text",
132128
"html_content": "<p>Newsletter body as HTML</p>",
133-
"idempotency_key": uuid::Uuid::new_v4().to_string()
129+
"idempotency_key": Uuid::new_v4().to_string()
134130
});
135131

136132
let response = app.post_publish_newsletters(&newsletter_request_body).await;
@@ -167,7 +163,7 @@ async fn newsletter_creation_is_idempotent() {
167163
"html_content": "<p>Newsletter body as HTML</p>",
168164
// We expect the idempotency key as part of the
169165
// form data, not as an header
170-
"idempotency_key": uuid::Uuid::new_v4().to_string()
166+
"idempotency_key": Uuid::new_v4().to_string()
171167
});
172168

173169
let response = app.post_publish_newsletters(&newsletter_request_body).await;
@@ -208,7 +204,7 @@ async fn concurrent_form_submission_is_handled_gracefully() {
208204
"title": "Newsletter title",
209205
"text_content": "Newsletter body as plain text",
210206
"html_content": "<p>Newsletter body as HTML</p>",
211-
"idempotency_key": uuid::Uuid::new_v4().to_string()
207+
"idempotency_key": Uuid::new_v4().to_string()
212208
});
213209

214210
let response_1 = app.post_publish_newsletters(&newsletter_request_body);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /