From ba1eac94827174b777d253fd86d030530d82a1b3 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 15 Jan 2023 07:21:45 +0900 Subject: [PATCH] Add test for blog title --- src/routes/blogs.rs | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index d854e05e..c7c3e588 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -397,11 +397,12 @@ mod tests { post_authors::{NewPostAuthor, PostAuthor}, posts::{NewPost, Post}, safe_string::SafeString, + search::Searcher, users::{NewUser, User, AUTH_COOKIE}, - Config, Fqn, SearchTokenizerConfig, search::Searcher, + Config, Fqn, SearchTokenizerConfig, }; use rocket::{ - http::{Cookie, Cookies, SameSite, Status}, + http::{ContentType, Cookie, Cookies, SameSite, Status}, local::{Client, LocalRequest}, }; @@ -519,6 +520,7 @@ mod tests { inbox_url: random_hex(), outbox_url: random_hex(), followers_endpoint: random_hex(), + fqn: random_hex(), ..Default::default() }; let user = User::insert(conn, user).unwrap(); @@ -593,4 +595,38 @@ mod tests { assert!(valid_slug("Blog Title").is_ok()); assert!(valid_slug("ブログ タイトル").is_ok()); } + + #[test] + fn create_blog_with_same_title_twice() { + let (client, (instance, user, blog, post)) = setup(); + + let new_path = uri!(super::new).to_string(); + let request = client.get(new_path); + login(&request, &user); + let mut response = request.dispatch(); + let body = response.body_string().unwrap(); + let prefix = r#"